- Another patch for bug 28074

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150347 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Otis Gospodnetic 2004-05-19 15:46:33 +00:00
parent 2a4dd6cb62
commit 1e2715d18d
1 changed files with 17 additions and 12 deletions

View File

@ -54,7 +54,7 @@ public final class FSDirectory extends Directory {
*/ */
public static final String LOCK_DIR = public static final String LOCK_DIR =
System.getProperty("org.apache.lucene.lockdir", System.getProperty("org.apache.lucene.lockdir",
System.getProperty("java.io.tmpdir", ".")); System.getProperty("java.io.tmpdir"));
private static MessageDigest DIGESTER; private static MessageDigest DIGESTER;
@ -118,17 +118,15 @@ public final class FSDirectory extends Directory {
private FSDirectory(File path, boolean create) throws IOException { private FSDirectory(File path, boolean create) throws IOException {
directory = path; directory = path;
lockDir = new File(LOCK_DIR); if (LOCK_DIR == null) {
if (!lockDir.isAbsolute()) { lockDir = directory;
lockDir = new File(directory, LOCK_DIR); }
} else {
if (lockDir.exists() == false) { lockDir = new File(LOCK_DIR);
if (lockDir.mkdirs() == false) { }
throw new IOException("Cannot create lock directory: " + lockDir); if (create) {
}
}
if (create)
create(); create();
}
if (!directory.isDirectory()) if (!directory.isDirectory())
throw new IOException(path + " not a directory"); throw new IOException(path + " not a directory");
@ -137,7 +135,7 @@ public final class FSDirectory extends Directory {
private synchronized void create() throws IOException { private synchronized void create() throws IOException {
if (!directory.exists()) if (!directory.exists())
if (!directory.mkdirs()) 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 String[] files = directory.list(); // clear old files
for (int i = 0; i < files.length; i++) { for (int i = 0; i < files.length; i++) {
@ -299,6 +297,13 @@ public final class FSDirectory extends Directory {
public boolean obtain() throws IOException { public boolean obtain() throws IOException {
if (DISABLE_LOCKS) if (DISABLE_LOCKS)
return true; return true;
if (!lockDir.exists()) {
if (!lockDir.mkdirs()) {
throw new IOException("Cannot create lock directory: " + lockDir);
}
}
return lockFile.createNewFile(); return lockFile.createNewFile();
} }
public void release() { public void release() {