Skip to content

Commit

Permalink
Fix lock name (bielu). Catch exception for empty old sync dir
Browse files Browse the repository at this point in the history
  • Loading branch information
nzdev committed Jan 9, 2021
1 parent 311f347 commit c4f9483
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/Examine.AzureDirectory/AzureReadOnlyLuceneDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public override void RebuildCache()
foreach (string file in GetAllBlobFiles())
{
// newIndex.TouchFile(file);
if ("write.lock".Equals(file))
if (file.EndsWith(".lock"))
{
continue;
}
Expand All @@ -121,19 +121,34 @@ public override void RebuildCache()
{
try
{
oldIndex.ClearLock("write.lock");
if (!string.IsNullOrEmpty(LockFactory.LockPrefix))
{
oldIndex.ClearLock(LockFactory.LockPrefix + "-write.lock");
}
else
{
oldIndex.ClearLock("write.lock");
}

}
catch (Exception ex)
{

Trace.WriteLine($"Error: {ex.ToString()}");
}
foreach (var file in oldIndex.ListAll())
try
{
if (oldIndex.FileExists(file))
foreach (var file in oldIndex.ListAll())
{
oldIndex.DeleteFile(file);
if (oldIndex.FileExists(file))
{
oldIndex.DeleteFile(file);
}
}
}
catch (NoSuchDirectoryException ex)
{
Trace.WriteLine($"Error: Old Local Sync Directory Empty. {ex.ToString()}");
}
oldIndex.Dispose();
DirectoryInfo oldindex = new DirectoryInfo(Path.Combine(_cacheDirectoryPath,
_cacheDirectoryName, OldIndexFolderName));
Expand Down

0 comments on commit c4f9483

Please sign in to comment.