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:
Andrew Gaul 2016-02-05 00:50:35 -08:00
parent 9feeee8347
commit 6cefc99cf0
1 changed files with 2 additions and 4 deletions

View File

@ -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();