lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [2/4] lucenenet git commit: ignore fsync for directory completely
Date Tue, 06 Jan 2015 13:24:51 GMT
ignore fsync for directory completely


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/1c1fc88c
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/1c1fc88c
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/1c1fc88c

Branch: refs/heads/master
Commit: 1c1fc88ce879610f4efa5788c74281bf739563f9
Parents: 7b8256c
Author: Laimonas Simutis <laimis@gmail.com>
Authored: Mon Jan 5 17:21:58 2015 -0500
Committer: Laimonas Simutis <laimis@gmail.com>
Committed: Mon Jan 5 17:21:58 2015 -0500

----------------------------------------------------------------------
 src/Lucene.Net.Core/Util/IOUtils.cs | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/1c1fc88c/src/Lucene.Net.Core/Util/IOUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/IOUtils.cs b/src/Lucene.Net.Core/Util/IOUtils.cs
index 581eb61..6147c4a 100644
--- a/src/Lucene.Net.Core/Util/IOUtils.cs
+++ b/src/Lucene.Net.Core/Util/IOUtils.cs
@@ -443,8 +443,11 @@ namespace Lucene.Net.Util
         ///  because not all file systems and operating systems allow to fsync on a directory)
</param>
         public static void Fsync(string fileToSync, bool isDir)
         {
-            // Fsync for folders appears to be "undefined" for Windows platform based on
the blog article in the comments below
-            if (isDir && Constants.WINDOWS)
+            // Fsync does not appear to function properly for Windows and Linux platforms.
In Lucene version
+            // they catch this in IOException branch and return if the call is for the directory.

+            // In Lucene.Net the exception is UnauthorizedAccessException and is not handled
by
+            // IOException block. No need to even attempt to fsync, just return if the call
is for directory
+            if (isDir)
             {
                 return;
             }
@@ -468,16 +471,10 @@ namespace Lucene.Net.Util
                     }
                     catch (IOException e)
                     {
-                        if (isDir)
-                        {
-                            Debug.Assert((Constants.LINUX || Constants.MAC_OS_X) == false,
-                                "On Linux and MacOSX fsyncing a directory should not throw
IOException, " +
-                                "we just don't want to rely on that in production (undocumented).
Got: " + e); // Ignore exception if it is a directory
-                            return;
-                        }
-
                         if (retryCount == 5)
+                        {
                             throw;
+                        }
 
                         // Pause 5 msec
                         Thread.Sleep(5);


Mime
View raw message