You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by dn...@apache.org on 2005/05/05 01:34:53 UTC
svn commit: r168213 - in /lucene/java/trunk: CHANGES.txt
src/java/org/apache/lucene/store/FSDirectory.java
Author: dnaber
Date: Wed May 4 16:34:52 2005
New Revision: 168213
URL: http://svn.apache.org/viewcvs?rev=168213&view=rev
Log:
only delete our own files when re-creating an index (#34695)
Modified:
lucene/java/trunk/CHANGES.txt
lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java
Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/CHANGES.txt?rev=168213&r1=168212&r2=168213&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Wed May 4 16:34:52 2005
@@ -32,6 +32,11 @@
ranking across multiple indices not to be equivalent.
(Chuck Williams, Wolf Siberski via Otis, bug #31841)
+ 5. When opening an IndexWriter with create=true, Lucene now only deletes
+ its own files from the index directory (looking at the file name suffixes
+ to decide if a file belongs to Lucene). The old behavior was to delete
+ all files. (Daniel Naber, bug #34695)
+
New features
1. Added support for stored compressed fields (patch #31149)
Modified: lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java?rev=168213&r1=168212&r2=168213&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java Wed May 4 16:34:52 2005
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import java.io.FilenameFilter;
import java.io.IOException;
import java.io.File;
import java.io.RandomAccessFile;
@@ -36,6 +37,36 @@
* @author Doug Cutting
*/
public class FSDirectory extends Directory {
+
+ /**
+ * Filter that only accepts filenames created by Lucene.
+ */
+ private class LuceneFileFilter implements FilenameFilter {
+
+ /* (non-Javadoc)
+ * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
+ */
+ public boolean accept(File dir, String name) {
+ if (name.endsWith(".cfs")) return true;
+ else if (name.endsWith(".fnm")) return true;
+ else if (name.endsWith(".fdt")) return true;
+ else if (name.endsWith(".fdx")) return true;
+ else if (name.endsWith(".frq")) return true;
+ else if (name.endsWith(".prx")) return true;
+ else if (name.endsWith(".tii")) return true;
+ else if (name.endsWith(".tis")) return true;
+ else if (name.endsWith(".tvd")) return true;
+ else if (name.endsWith(".tvf")) return true;
+ else if (name.endsWith(".tvx")) return true;
+ else if (name.endsWith(".del")) return true;
+ else if (name.equals("deletable")) return true;
+ else if (name.equals("segments")) return true;
+ else if (name.matches(".+\\.f\\d+")) return true;
+ return false;
+ }
+
+ }
+
/** This cache of directories ensures that there is a unique Directory
* instance per path, so that synchronization on the Directory can be used to
* synchronize access between readers and writers.
@@ -157,7 +188,7 @@
if (!directory.mkdirs())
throw new IOException("Cannot create directory: " + directory);
- String[] files = directory.list(); // clear old files
+ String[] files = directory.list(new LuceneFileFilter()); // clear old files
for (int i = 0; i < files.length; i++) {
File file = new File(directory, files[i]);
if (!file.delete())
Re: svn commit: r168213 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/store/FSDirectory.java
Posted by Daniel Naber <lu...@danielnaber.de>.
On Thursday 05 May 2005 01:40, Doug Cutting wrote:
> I'd prefer if the list of file extensions was in a single place, and
> that place should be somewhere in the index package, not in the store
> package.
I will try to move it. BTW, index/SegmentReader.java refers to an extension
"tvp" which I cannot find anywhere. I guess this reference can be removed?
Regards
Daniel
--
http://www.danielnaber.de
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: svn commit: r168213 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/store/FSDirectory.java
Posted by Daniel Naber <lu...@danielnaber.de>.
On Thursday 05 May 2005 01:40, Doug Cutting wrote:
> I'd prefer if the list of file extensions was in a single place, and
> that place should be somewhere in the index package, not in the store
> package.
I attached a new patch here:
http://issues.apache.org/bugzilla/show_bug.cgi?id=34695
Regards
Daniel
--
http://www.danielnaber.de
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: svn commit: r168213 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/store/FSDirectory.java
Posted by Doug Cutting <cu...@apache.org>.
I'd prefer if the list of file extensions was in a single place, and
that place should be somewhere in the index package, not in the store
package.
Doug
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org