lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Willnauer (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-638) Can't put non-index files (e.g. CVS, SVN directories) in a Lucene index directory
Date Fri, 28 Jul 2006 12:40:16 GMT
    [ http://issues.apache.org/jira/browse/LUCENE-638?page=comments#action_12424084 ] 
            
Simon Willnauer commented on LUCENE-638:
----------------------------------------

The RAMDirectory class uses the Directory.list() method to create the index input in the constructor.
The implementation of FSDirectory returns all containing files of the directory including
non lucene files and also all containing directories. 
In my opinion this method should not return non lucene files and directories for consistency.

The problem does only appear if you create a RamDirectory from a existing index.

here is the patch for the trunk: 
(I also added a try / finally block in the rename() method to close all streams in the case
of an exception on the input stream the output stream would remain open.)
All test passed, almost no tests in the store package :).


Index: FSDirectory.java
===================================================================
--- FSDirectory.java    (revision 426479) 
+++ FSDirectory.java    (working copy) 
@@ -211,9 +211,9 @@
     }
   }
 
-  /** Returns an array of strings, one for each file in the directory. */ 
+  /** Returns an array of strings, one for each lucnene index file in the directory. */ 
   public String[] list() {
-    return directory.list(); 
+    return directory.list(new IndexFileNameFilter()); 
   }
 
   /** Returns true iff a file with the given name exists. */
@@ -296,20 +296,23 @@
         throw newExc;
       }
       finally {
-        if (in != null) { 
-          try { 
-            in.close(); 
-          } catch (IOException e) { 
-            throw new RuntimeException("Cannot close input stream: " + e.toString(), e);

+    try{       
+          if (in != null) { 
+            try { 
+              in.close(); 
+            } catch (IOException e) { 
+              throw new RuntimeException("Cannot close input stream: " + e.toString(), e);

+            } 
           }
-        } 
-        if (out != null) { 
-          try { 
-            out.close(); 
-          } catch (IOException e) { 
-            throw new RuntimeException("Cannot close output stream: " + e.toString(), e);

+    }finally{ 
+          if (out != null) { 
+            try { 
+              out.close(); 
+            } catch (IOException e) { 
+              throw new RuntimeException("Cannot close output stream: " + e.toString(), e);

+            } 
           }
-        } 
+    } 
       }
     }
   }

> Can't put non-index files (e.g. CVS, SVN directories) in a Lucene index directory
> ---------------------------------------------------------------------------------
>
>                 Key: LUCENE-638
>                 URL: http://issues.apache.org/jira/browse/LUCENE-638
>             Project: Lucene - Java
>          Issue Type: Bug
>            Reporter: Eleanor Joslin
>            Priority: Minor
>         Attachments: LuceneTest.java
>
>
> Lucene won't tolerate foreign files in its index directories.  This makes it impossible
to keep an index in a CVS or Subversion repository.
> For instance, this exception appears when creating a RAMDirectory from a java.io.File
that contains a subdirectory called ".svn".
> java.io.FileNotFoundException: /home/local/ejj/ic/.caches/.search/.index/.svn
> (Is a directory)
>         at java.io.RandomAccessFile.open(Native Method)
>         at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
>         at
> org.apache.lucene.store.FSIndexInput$Descriptor.<init>(FSDirectory.java:425)
>         at org.apache.lucene.store.FSIndexInput.<init>(FSDirectory.java:434)
>         at org.apache.lucene.store.FSDirectory.openInput(FSDirectory.java:324)
>         at org.apache.lucene.store.RAMDirectory.<init>(RAMDirectory.java:61)
>         at org.apache.lucene.store.RAMDirectory.<init>(RAMDirectory.java:86)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message