mirror of https://github.com/apache/lucene.git
LUCENE-5588: Workaround for fsyncing non-existing directory
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1586475 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
63d67496cf
commit
d825efca44
|
@ -289,10 +289,15 @@ public abstract class FSDirectory extends BaseDirectory {
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue