lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/store FSDirectory.java
Date Thu, 11 Oct 2001 17:21:10 GMT
cutting     01/10/11 10:21:10

  Modified:    src/java/org/apache/lucene/store FSDirectory.java
  Log:
  Fixed so that getDirectory(xxx,true) correctly erases the directory
  contents, even when the directory has already been accessed in this
  JVM.  This was broken by the thread-safety fix.
  
  Revision  Changes    Path
  1.4       +16 -10    jakarta-lucene/src/java/org/apache/lucene/store/FSDirectory.java
  
  Index: FSDirectory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/FSDirectory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FSDirectory.java	2001/10/10 16:13:41	1.3
  +++ FSDirectory.java	2001/10/11 17:21:10	1.4
  @@ -109,6 +109,8 @@
         if (dir == null) {
   	dir = new FSDirectory(file, create);
   	DIRECTORIES.put(file, dir);
  +      } else if (create) {
  +        dir.create();
         }
       }
       synchronized (dir) {
  @@ -122,20 +124,24 @@
   
     private FSDirectory(File path, boolean create) throws IOException {
       directory = path;
  -    if (!directory.exists() && create)
  -      directory.mkdir();
  +
  +    if (create)
  +      create();
  +
       if (!directory.isDirectory())
         throw new IOException(path + " not a directory");
  +  }
   
  -    if (create) {				  // clear old files
  -      String[] files = directory.list();
  -      for (int i = 0; i < files.length; i++) {
  -	File file = new File(directory, files[i]);
  -	if (!file.delete())
  -	  throw new IOException("couldn't delete " + files[i]);
  -      }
  -    }
  +  private synchronized void create() throws IOException {
  +    if (!directory.exists())
  +      directory.mkdir();
   
  +    String[] files = directory.list();            // clear old files
  +    for (int i = 0; i < files.length; i++) {
  +      File file = new File(directory, files[i]);
  +      if (!file.delete())
  +        throw new IOException("couldn't delete " + files[i]);
  +    }
     }
   
     /** Returns an array of strings, one for each file in the directory. */
  
  
  

Mime
View raw message