Use simpler write-once semantics for FS repository (#30435)
The writeBlob method for FsBlobContainer already opens the file with StandardOpenOption.CREATE_NEW, so there's no need for an extra blobExists(blobName) check.
This commit is contained in:
parent
09cf530f4b
commit
cdcd4a1129
|
@ -123,9 +123,6 @@ public class FsBlobContainer extends AbstractBlobContainer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeBlob(String blobName, InputStream inputStream, long blobSize) throws IOException {
|
public void writeBlob(String blobName, InputStream inputStream, long blobSize) throws IOException {
|
||||||
if (blobExists(blobName)) {
|
|
||||||
throw new FileAlreadyExistsException("blob [" + blobName + "] already exists, cannot overwrite");
|
|
||||||
}
|
|
||||||
final Path file = path.resolve(blobName);
|
final Path file = path.resolve(blobName);
|
||||||
try (OutputStream outputStream = Files.newOutputStream(file, StandardOpenOption.CREATE_NEW)) {
|
try (OutputStream outputStream = Files.newOutputStream(file, StandardOpenOption.CREATE_NEW)) {
|
||||||
Streams.copy(inputStream, outputStream);
|
Streams.copy(inputStream, outputStream);
|
||||||
|
|
Loading…
Reference in New Issue