mirror of https://github.com/apache/jclouds.git
JCLOUDS-1111: Overwrite objects via remove and put
This partially reverts commit
e446b5b8b4
. AT&T Synaptic returns a
bogus error on with x-emc-force-overwrite:
HTTP 400, code=1012, message=There was a mismatch between the object
size and the specified extent size.
This commit is contained in:
parent
343897d6d8
commit
b2ced53e16
|
@ -267,7 +267,6 @@ public class AtmosBlobStore extends BaseBlobStore {
|
|||
if (options.getBlobAccess() == BlobAccess.PUBLIC_READ) {
|
||||
atmosOptions.publicRead();
|
||||
}
|
||||
atmosOptions.overwrite();
|
||||
return AtmosUtils.putBlob(sync, crypto, blob2Object, container, blob, atmosOptions);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,11 @@ public class PutOptions extends BaseHttpRequestOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
/** By default Atmos does not allow overwriting objects. */
|
||||
/**
|
||||
* By default Atmos does not allow overwriting objects.
|
||||
*
|
||||
* Note: older versions of Atmos do not support this header.
|
||||
*/
|
||||
public PutOptions overwrite() {
|
||||
this.replaceHeader("x-emc-force-overwrite", "true");
|
||||
return this;
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.jclouds.atmos.options.PutOptions;
|
|||
import org.jclouds.atmos.reference.AtmosErrorCode;
|
||||
import org.jclouds.atmos.xml.ErrorHandler;
|
||||
import org.jclouds.blobstore.ContainerNotFoundException;
|
||||
import org.jclouds.blobstore.KeyAlreadyExistsException;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
import org.jclouds.http.HttpCommand;
|
||||
|
@ -71,7 +72,13 @@ public class AtmosUtils {
|
|||
Blob blob, PutOptions options) {
|
||||
final String path = container + "/" + blob.getMetadata().getName();
|
||||
final AtmosObject object = blob2Object.apply(blob);
|
||||
sync.createFile(container, object, options);
|
||||
|
||||
try {
|
||||
sync.createFile(container, object, options);
|
||||
} catch (KeyAlreadyExistsException e) {
|
||||
deletePathAndEnsureGone(sync, path);
|
||||
sync.createFile(container, object, options);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue