Apache Solr open-source search software
Fixed a bug in IndexReader.lastModified().
Doug Cutting689293d13b30
diff --git a/CHANGES.txt b/CHANGES.txtindex aa37954251f..7adab2ee572 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -85,7 +85,10 @@ $Id$need to be reconstructed once per day. (cutting)15. Added a new IndexWriter method, getAnalyzer(). This returns the- analyzer used when adding documents to this index.+ analyzer used when adding documents to this index. (cutting)++ 16. Fixed a bug with IndexReader.lastModified(). Before, document+ deletion did not update this. Now it does. (cutting)1.2 RC6diff --git a/src/java/org/apache/lucene/index/SegmentReader.java b/src/java/org/apache/lucene/index/SegmentReader.javaindex bbf07f1ba80..5435732788b 100644--- a/src/java/org/apache/lucene/index/SegmentReader.java+++ b/src/java/org/apache/lucene/index/SegmentReader.java@@ -121,6 +121,7 @@ final class SegmentReader extends IndexReader {public Object doBody() throws IOException {deletedDocs.write(directory, segment + ".tmp");directory.renameFile(segment + ".tmp", segment + ".del");+ directory.touchFile("segments");return null;}}.run();diff --git a/src/java/org/apache/lucene/store/Directory.java b/src/java/org/apache/lucene/store/Directory.javaindex c96586293d9..4670b18b468 100644--- a/src/java/org/apache/lucene/store/Directory.java+++ b/src/java/org/apache/lucene/store/Directory.java@@ -82,6 +82,10 @@ abstract public class Directory {abstract public long fileModified(String name)throws IOException, SecurityException;+ /** Set the modified time of an existing file to now. */+ abstract public void touchFile(String name)+ throws IOException, SecurityException;+/** Removes an existing file in the directory. */abstract public void deleteFile(String name)throws IOException, SecurityException;diff --git a/src/java/org/apache/lucene/store/FSDirectory.java b/src/java/org/apache/lucene/store/FSDirectory.javaindex b2c0a23658f..47babd2f844 100644--- a/src/java/org/apache/lucene/store/FSDirectory.java+++ b/src/java/org/apache/lucene/store/FSDirectory.java@@ -175,6 +175,12 @@ final public class FSDirectory extends Directory {return file.lastModified();}+ /** Set the modified time of an existing file to now. */+ public void touchFile(String name) throws IOException, SecurityException {+ File file = new File(directory, name);+ file.setLastModified(System.currentTimeMillis());+ }+/** Returns the length in bytes of a file in the directory. */public final long fileLength(String name) throws IOException {File file = new File(directory, name);diff --git a/src/java/org/apache/lucene/store/RAMDirectory.java b/src/java/org/apache/lucene/store/RAMDirectory.javaindex da780bffe26..2e016db554f 100644--- a/src/java/org/apache/lucene/store/RAMDirectory.java+++ b/src/java/org/apache/lucene/store/RAMDirectory.java@@ -93,6 +93,12 @@ final public class RAMDirectory extends Directory {return file.lastModified;}+ /** Set the modified time of an existing file to now. */+ public void touchFile(String name) throws IOException, SecurityException {+ RAMFile file = (RAMFile)files.get(name);+ file.lastModified = System.currentTimeMillis();+ }+/** Returns the length in bytes of a file in the directory. */public final long fileLength(String name) {RAMFile file = (RAMFile)files.get(name);