Skip to content

Apache Lucene open-source search software

ensureCanWrite is not necessary since we pass TRUNCATE_EXISTING

Mike McCandless72b79308cbce
diff --git a/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java b/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
index d02c12684da..400ad5d0e61 100644
--- a/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
+++ b/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
@@ -228,7 +228,6 @@ public abstract class FSDirectory extends BaseDirectory {
@Override
public IndexOutput createOutput(String name, IOContext context) throws IOException {
ensureOpen();
- ensureCanWrite(name);
return new FSIndexOutput(name);
}
@@ -246,10 +245,6 @@ public abstract class FSDirectory extends BaseDirectory {
}
}
- protected void ensureCanWrite(String name) throws IOException {
- Files.deleteIfExists(directory.resolve(name)); // delete existing, if any
- }
-
@Override
public void sync(Collection<String> names) throws IOException {
ensureOpen();
diff --git a/lucene/misc/src/java/org/apache/lucene/store/NativeUnixDirectory.java b/lucene/misc/src/java/org/apache/lucene/store/NativeUnixDirectory.java
index 43763e21d85..51d7e92aa28 100644
--- a/lucene/misc/src/java/org/apache/lucene/store/NativeUnixDirectory.java
+++ b/lucene/misc/src/java/org/apache/lucene/store/NativeUnixDirectory.java
@@ -148,7 +148,6 @@ public class NativeUnixDirectory extends FSDirectory {
if (context.context != Context.MERGE || context.mergeInfo.estimatedMergeBytes < minBytesDirect) {
return delegate.createOutput(name, context);
} else {
- ensureCanWrite(name);
return new NativeUnixIndexOutput(getDirectory().resolve(name), name, mergeBufferSize);
}
}