Skip to content

Commit cdcd4a1

Browse files
authored
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.
1 parent 09cf530 commit cdcd4a1

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

server/src/main/java/org/elasticsearch/common/blobstore/fs/FsBlobContainer.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ public InputStream readBlob(String name) throws IOException {
123123

124124
@Override
125125
public void writeBlob(String blobName, InputStream inputStream, long blobSize) throws IOException {
126-
if (blobExists(blobName)) {
127-
throw new FileAlreadyExistsException("blob [" + blobName + "] already exists, cannot overwrite");
128-
}
129126
final Path file = path.resolve(blobName);
130127
try (OutputStream outputStream = Files.newOutputStream(file, StandardOpenOption.CREATE_NEW)) {
131128
Streams.copy(inputStream, outputStream);

0 commit comments

Comments
 (0)