From 80c54757258fb492cd83434c508b7dc56ceeb97a Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Thu, 5 Jul 2012 09:55:16 +0000 Subject: [PATCH] LUCENE-4190: revert. lucene isn't a file manager git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1357532 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 5 ----- .../apache/lucene/index/IndexFileDeleter.java | 3 +-- .../org/apache/lucene/index/SegmentInfo.java | 13 ------------ .../test/org/apache/lucene/index/TestDoc.java | 12 +++++------ .../apache/lucene/index/TestIndexWriter.java | 20 ------------------- 5 files changed, 7 insertions(+), 46 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 7705b6dac51..147a1c0c881 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -15,11 +15,6 @@ New features create automata from a fixed collection of UTF-8 encoded BytesRef (Dawid Weiss, Robert Muir) -Changes in Runtime Behavior - -* LUCENE-4190: Don't delete files in the index directory unless they - begin with an underscore. (Mike McCandless, Robert Muir) - API Changes * LUCENE-4138: update of morfologik (Polish morphological analyzer) to 1.5.3. diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java b/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java index 1d2bdef0d66..4447472779c 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java @@ -149,8 +149,7 @@ final class IndexFileDeleter { for (String fileName : files) { - if (!fileName.endsWith("write.lock") && !fileName.equals(IndexFileNames.SEGMENTS_GEN) - && (fileName.startsWith("_") || fileName.startsWith(IndexFileNames.SEGMENTS))) { + if (!fileName.endsWith("write.lock") && !fileName.equals(IndexFileNames.SEGMENTS_GEN)) { // Add this file to refCounts with initial count 0: getRefCount(fileName); diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java index 4b20d3f0015..e6f2b0ebdc1 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java +++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java @@ -244,27 +244,14 @@ public final class SegmentInfo { public void setFiles(Set files) { setFiles = files; sizeInBytes = -1; - assert assertSaneFileNames(); } public void addFiles(Collection files) { setFiles.addAll(files); - sizeInBytes = -1; - assert assertSaneFileNames(); } public void addFile(String file) { setFiles.add(file); - sizeInBytes = -1; - assert assertSaneFileNames(); - } - - // used only by assert - private boolean assertSaneFileNames() { - for (String file : setFiles) { - assert file.startsWith("_") : "invalid codec filename: " + file ; - } - return true; } /** diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDoc.java b/lucene/core/src/test/org/apache/lucene/index/TestDoc.java index 8a31910db59..b345f82b452 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestDoc.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestDoc.java @@ -125,13 +125,13 @@ public class TestDoc extends LuceneTestCase { printSegment(out, si2); writer.close(); - SegmentInfoPerCommit siMerge = merge(directory, si1, si2, "_merge", false); + SegmentInfoPerCommit siMerge = merge(directory, si1, si2, "merge", false); printSegment(out, siMerge); - SegmentInfoPerCommit siMerge2 = merge(directory, si1, si2, "_merge2", false); + SegmentInfoPerCommit siMerge2 = merge(directory, si1, si2, "merge2", false); printSegment(out, siMerge2); - SegmentInfoPerCommit siMerge3 = merge(directory, siMerge, siMerge2, "_merge3", false); + SegmentInfoPerCommit siMerge3 = merge(directory, siMerge, siMerge2, "merge3", false); printSegment(out, siMerge3); directory.close(); @@ -160,13 +160,13 @@ public class TestDoc extends LuceneTestCase { printSegment(out, si2); writer.close(); - siMerge = merge(directory, si1, si2, "_merge", true); + siMerge = merge(directory, si1, si2, "merge", true); printSegment(out, siMerge); - siMerge2 = merge(directory, si1, si2, "_merge2", true); + siMerge2 = merge(directory, si1, si2, "merge2", true); printSegment(out, siMerge2); - siMerge3 = merge(directory, siMerge, siMerge2, "_merge3", true); + siMerge3 = merge(directory, siMerge, siMerge2, "merge3", true); printSegment(out, siMerge3); directory.close(); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java index 43c03a89530..195c455f182 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java @@ -45,7 +45,6 @@ import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TermQuery; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.Directory; -import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.Lock; import org.apache.lucene.store.LockFactory; import org.apache.lucene.store.LockObtainFailedException; @@ -1800,23 +1799,4 @@ public class TestIndexWriter extends LuceneTestCase { r.close(); dir.close(); } - - //LUCENE-1468 -- make sure opening an IndexWriter with - // create=true does not remove non-index files - - public void testOtherFiles() throws Throwable { - Directory dir = newDirectory(); - try { - // Create my own random file: - IndexOutput out = dir.createOutput("myrandomfile", newIOContext(random())); - out.writeByte((byte) 42); - out.close(); - - new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random()))).close(); - - assertTrue(dir.fileExists("myrandomfile")); - } finally { - dir.close(); - } - } }