public void CleanLock()
{
bool deleteLockFileOnStart;
if (bool.TryParse(cmsConfiguration.Search.GetValue(LuceneSearchConstants.ConfigurationKeys.LuceneIndexerDeleteLockFileOnStart), out deleteLockFileOnStart) && deleteLockFileOnStart)
{
try
{
var fileSystemPath = cmsConfiguration.Search.GetValue(LuceneSearchConstants.ConfigurationKeys.LuceneFileSystemDirectory);
if (string.IsNullOrWhiteSpace(fileSystemPath))
{
Log.Info("Lucene file system path is not set.");
return;
}
directory = GetLuceneDirectory(fileSystemPath);
var path = Path.Combine(directory, IndexWriter.WRITE_LOCK_NAME);
if (File.Exists(path))
{
File.Delete(path);
}
}
catch (Exception ex)
{
Log.Error(string.Format("Failed to delete write lock file '{0}' in directory '{1}'.", IndexWriter.WRITE_LOCK_NAME, directory), ex);
}
}
}