In almost all cases we write uuid named files via this method. Preemptively deleting just wastes IO ops, we can delete after a write failed and retry the write to cover the few cases where we actually do an overwrite.
This commit is contained in:
parent
53fa52d618
commit
196ed6b90e
|
@ -176,11 +176,16 @@ public class FsBlobContainer extends AbstractBlobContainer {
|
|||
|
||||
@Override
|
||||
public void writeBlob(String blobName, InputStream inputStream, long blobSize, boolean failIfAlreadyExists) throws IOException {
|
||||
if (failIfAlreadyExists == false) {
|
||||
deleteBlobsIgnoringIfNotExists(Collections.singletonList(blobName));
|
||||
}
|
||||
final Path file = path.resolve(blobName);
|
||||
writeToPath(inputStream, file, blobSize);
|
||||
try {
|
||||
writeToPath(inputStream, file, blobSize);
|
||||
} catch (FileAlreadyExistsException faee) {
|
||||
if (failIfAlreadyExists) {
|
||||
throw faee;
|
||||
}
|
||||
deleteBlobsIgnoringIfNotExists(Collections.singletonList(blobName));
|
||||
writeToPath(inputStream, file, blobSize);
|
||||
}
|
||||
IOUtils.fsync(path, true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue