You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2014/04/10 23:53:55 UTC
svn commit: r1586475 -
/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
Author: uschindler
Date: Thu Apr 10 21:53:54 2014
New Revision: 1586475
URL: http://svn.apache.org/r1586475
Log:
LUCENE-5588: Workaround for fsyncing non-existing directory
Modified:
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java?rev=1586475&r1=1586474&r2=1586475&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java Thu Apr 10 21:53:54 2014
@@ -289,10 +289,15 @@ public abstract class FSDirectory extend
Set<String> toSync = new HashSet<>(names);
toSync.retainAll(staleFiles);
- for (String name : toSync)
+ for (String name : toSync) {
fsync(name);
+ }
- IOUtils.fsync(directory, true);
+ // fsync the directory itsself, but only if there was any file fsynced before
+ // (otherwise it can happen that the directory does not yet exist)!
+ if (!toSync.isEmpty()) {
+ IOUtils.fsync(directory, true);
+ }
staleFiles.removeAll(toSync);
}