otis        2004/05/19 08:46:33

  Modified:    src/java/org/apache/lucene/store FSDirectory.java
  Log:
  - Another patch for bug 28074
  
  Revision  Changes    Path
  1.32      +17 -12    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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- FSDirectory.java  18 May 2004 13:42:30 -0000      1.31
  +++ FSDirectory.java  19 May 2004 15:46:33 -0000      1.32
  @@ -54,7 +54,7 @@
      */
     public static final String LOCK_DIR =
       System.getProperty("org.apache.lucene.lockdir",
  -      System.getProperty("java.io.tmpdir", "."));
  +      System.getProperty("java.io.tmpdir"));
   
     private static MessageDigest DIGESTER;
   
  @@ -118,17 +118,15 @@
     private FSDirectory(File path, boolean create) throws IOException {
       directory = path;
   
  -   lockDir = new File(LOCK_DIR);
  -   if (!lockDir.isAbsolute()) {
  -     lockDir = new File(directory, LOCK_DIR);
  -   }
  -   if (lockDir.exists() == false) {
  -     if (lockDir.mkdirs() == false) {
  -       throw new IOException("Cannot create lock directory: " + lockDir);
  -     }
  -   }
  -    if (create)
  +    if (LOCK_DIR == null) {
  +      lockDir = directory;
  +    }
  +    else {
  +      lockDir = new File(LOCK_DIR);
  +    }
  +    if (create) {
         create();
  +    }
   
       if (!directory.isDirectory())
         throw new IOException(path + " not a directory");
  @@ -137,7 +135,7 @@
     private synchronized void create() throws IOException {
       if (!directory.exists())
         if (!directory.mkdirs())
  -        throw new IOException("Cannot create lock directory: " + directory);
  +        throw new IOException("Cannot create directory: " + directory);
   
       String[] files = directory.list();            // clear old files
       for (int i = 0; i < files.length; i++) {
  @@ -299,6 +297,13 @@
         public boolean obtain() throws IOException {
           if (DISABLE_LOCKS)
             return true;
  +
  +        if (!lockDir.exists()) {
  +          if (!lockDir.mkdirs()) {
  +            throw new IOException("Cannot create lock directory: " + lockDir);
  +          }
  +        }
  +
           return lockFile.createNewFile();
         }
         public void release() {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to