diff --git a/src/DotJEM.Json.Index2.Management/Writer/IJsonIndexWriter.cs b/src/DotJEM.Json.Index2.Management/Writer/IJsonIndexWriter.cs index ef535bc..4e583d5 100644 --- a/src/DotJEM.Json.Index2.Management/Writer/IJsonIndexWriter.cs +++ b/src/DotJEM.Json.Index2.Management/Writer/IJsonIndexWriter.cs @@ -150,14 +150,16 @@ private void Commit() if (callsRead < 1) return; + using ILease lease = target.WriterLease; try { - using ILease lease = target.WriterLease; lease.Value.Commit(); } catch (Exception e) { - target.infoStream.WriteError("Failed to commit indexed data to storage.", e); + bool leaseExpired = lease.IsExpired; + + target.infoStream.WriteError($"Failed to commit indexed data to storage. {leaseExpired}", e); // SWALLOW FOR NOW } } diff --git a/src/DotJEM.Json.Index2/IO/JsonIndexWriterManager.cs b/src/DotJEM.Json.Index2/IO/JsonIndexWriterManager.cs index d00f80d..60ad7d3 100644 --- a/src/DotJEM.Json.Index2/IO/JsonIndexWriterManager.cs +++ b/src/DotJEM.Json.Index2/IO/JsonIndexWriterManager.cs @@ -165,7 +165,7 @@ public IndexWriter Value } } - public bool IsExpired => DateTime.Now - leaseTime > TimeSpan.FromSeconds(5); + public bool IsExpired => (DateTime.Now - leaseTime > TimeSpan.FromSeconds(5)) || IsDisposed; public TimeLimitedIndexWriterLease(IndexWriterManager manager, Action onReturned) { @@ -181,9 +181,6 @@ protected override void Dispose(bool disposing) public void Wait() { - if (IsDisposed) - return; - if (IsExpired) return; diff --git a/src/DotJEM.Json.Index2/Storage/IJsonIndexStorageManager.cs b/src/DotJEM.Json.Index2/Storage/IJsonIndexStorageManager.cs index b634983..9402776 100644 --- a/src/DotJEM.Json.Index2/Storage/IJsonIndexStorageManager.cs +++ b/src/DotJEM.Json.Index2/Storage/IJsonIndexStorageManager.cs @@ -36,9 +36,6 @@ public Directory Directory { get { - if (directory != null) - return directory; - lock (padlock) { if (directory != null) @@ -83,6 +80,8 @@ public void Delete() foreach (string file in directory.ListAll()) directory.DeleteFile(file); provider.Delete(); + + } } } \ No newline at end of file