Various FSDirectory fixes for file locking

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

Branch: refs/heads/branch_4x
Commit: eef5d7a0be39016ce8680d25d976c86f1de534ae
Parents: e7d9204
Author: Paul Irwin <[email protected]>
Authored: Tue Nov 12 15:39:29 2013 -0500
Committer: Paul Irwin <[email protected]>
Committed: Tue Nov 12 15:39:29 2013 -0500

----------------------------------------------------------------------
 src/core/Store/FSDirectory.cs   | 8 ++++----
 src/core/Store/MMapDirectory.cs | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/eef5d7a0/src/core/Store/FSDirectory.cs
----------------------------------------------------------------------
diff --git a/src/core/Store/FSDirectory.cs b/src/core/Store/FSDirectory.cs
index f5a5ce0..8b9f817 100644
--- a/src/core/Store/FSDirectory.cs
+++ b/src/core/Store/FSDirectory.cs
@@ -473,7 +473,7 @@ namespace Lucene.Net.Store
             protected FSIndexInput(string resourceDesc, FileInfo path, 
IOContext context, int chunkSize)
                 : base(resourceDesc, context)
             {
-                this.file = path.OpenRead();
+                this.file = new FileStream(path.FullName, FileMode.Open, 
FileAccess.Read, FileShare.ReadWrite);
                 this.chunkSize = chunkSize;
                 this.off = 0L;
                 this.end = file.Length;
@@ -543,6 +543,7 @@ namespace Lucene.Net.Store
             {
                 //assert isOpen;
                 file.Write(b, offset, size);
+                file.Flush();
             }
 
             protected override void Dispose(bool disposing)
@@ -611,9 +612,8 @@ namespace Lucene.Net.Store
                 {
                     try
                     {
-                        file = new FileStream(fullFile.FullName, 
FileMode.OpenOrCreate, FileAccess.ReadWrite);
-                        //file.getFD().sync();
-                        // TODO: .NET Port: what do we do here?
+                        file = new System.IO.FileStream(fullFile.FullName, 
System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, 
System.IO.FileShare.ReadWrite);
+                        FileSupport.Sync(file);
                         success = true;
                     }
                     finally

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/eef5d7a0/src/core/Store/MMapDirectory.cs
----------------------------------------------------------------------
diff --git a/src/core/Store/MMapDirectory.cs b/src/core/Store/MMapDirectory.cs
index 051b9e8..b6b8556 100644
--- a/src/core/Store/MMapDirectory.cs
+++ b/src/core/Store/MMapDirectory.cs
@@ -172,7 +172,7 @@ namespace Lucene.Net.Store
         {
             EnsureOpen();
             String path = System.IO.Path.Combine(Directory.FullName, name);
-            System.IO.FileStream raf = new System.IO.FileStream(path, 
System.IO.FileMode.Open, System.IO.FileAccess.Read);
+            System.IO.FileStream raf = new System.IO.FileStream(path, 
System.IO.FileMode.Open, System.IO.FileAccess.Read, 
System.IO.FileShare.ReadWrite);
             try
             {
                 return new MMapIndexInput(this, "MMapIndexInput(path=\"" + 
path + "\")", raf, path);

Reply via email to