mirror of https://github.com/apache/jclouds.git
Do not check for equality on overwrites
Firstly, this check never triggered because Payload.equals always returns false for File objects. Secondly, this would not reduce IO even if it worked since the common case is not overwriting a file with the same contents. Lastly, simplify a cast.
This commit is contained in:
parent
596cf4e044
commit
7cbfd42736
apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal
|
@ -199,15 +199,11 @@ public class FilesystemStorageStrategyImpl implements FilesystemStorageStrategy
|
||||||
filesystemContainerNameValidator.validate(container);
|
filesystemContainerNameValidator.validate(container);
|
||||||
filesystemBlobKeyValidator.validate(blobKey);
|
filesystemBlobKeyValidator.validate(blobKey);
|
||||||
File outputFile = getFileForBlobKey(container, blobKey);
|
File outputFile = getFileForBlobKey(container, blobKey);
|
||||||
if (payload.getRawContent().equals(outputFile)){
|
|
||||||
// we shouldn't re-copy the same contents
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FileOutputStream output = null;
|
FileOutputStream output = null;
|
||||||
try {
|
try {
|
||||||
Files.createParentDirs(outputFile);
|
Files.createParentDirs(outputFile);
|
||||||
if (payload.getRawContent() instanceof File)
|
if (payload.getRawContent() instanceof File)
|
||||||
Files.copy(File.class.cast(payload.getRawContent()), outputFile);
|
Files.copy((File) payload.getRawContent(), outputFile);
|
||||||
else {
|
else {
|
||||||
output = new FileOutputStream(outputFile);
|
output = new FileOutputStream(outputFile);
|
||||||
payload.writeTo(output);
|
payload.writeTo(output);
|
||||||
|
|
Loading…
Reference in New Issue