mirror of https://github.com/apache/jclouds.git
Always delete tmpFile in filesystem putBlob
Previously we would only do this on the exceptional path. Also throw IOException on failed rename for consistency.
This commit is contained in:
parent
9feeee8347
commit
6cefc99cf0
|
@ -494,11 +494,11 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
|
||||||
setBlobAccess(containerName, tmpBlobName, BlobAccess.PRIVATE);
|
setBlobAccess(containerName, tmpBlobName, BlobAccess.PRIVATE);
|
||||||
|
|
||||||
if (!tmpFile.renameTo(outputFile)) {
|
if (!tmpFile.renameTo(outputFile)) {
|
||||||
throw new RuntimeException("Could not rename file " + tmpFile + " to " + outputFile);
|
throw new IOException("Could not rename file " + tmpFile + " to " + outputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return base16().lowerCase().encode(actualHashCode.asBytes());
|
return base16().lowerCase().encode(actualHashCode.asBytes());
|
||||||
} catch (IOException ex) {
|
} finally {
|
||||||
if (tmpFile != null) {
|
if (tmpFile != null) {
|
||||||
try {
|
try {
|
||||||
delete(tmpFile);
|
delete(tmpFile);
|
||||||
|
@ -506,8 +506,6 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
|
||||||
logger.debug("Could not delete %s: %s", tmpFile, e);
|
logger.debug("Could not delete %s: %s", tmpFile, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw ex;
|
|
||||||
} finally {
|
|
||||||
closeQuietly(his);
|
closeQuietly(his);
|
||||||
if (payload != null) {
|
if (payload != null) {
|
||||||
payload.release();
|
payload.release();
|
||||||
|
|
Loading…
Reference in New Issue