private void RemoveIndexWriterLockFile()
{
//delete write.lock if necessary
var lockFilePath = StorageContext.Search.IndexLockFilePath;
if (lockFilePath == null)
return;
if (System.IO.File.Exists(lockFilePath))
{
_startupInfo.IndexWasReadOnly = true;
var endRetry = DateTime.Now.AddSeconds(RepositoryConfiguration.LuceneLockDeleteRetryInterval);
//retry write.lock for a given period of time
while (true)
{
try
{
System.IO.File.Delete(lockFilePath);
break;
}
catch (Exception ex)
{
System.Threading.Thread.Sleep(5000);
if (DateTime.Now > endRetry)
throw new System.IO.IOException("Cannot remove the index lock: " + ex.Message, ex);
}
}
}
else
{
_startupInfo.IndexWasReadOnly = false;
ConsoleWriteLine("Index directory is read/write.");
}
}
private void RegisterAppdomainEventHandlers()