create notion of locked path

This commit is contained in:
Luke Pulverenti 2016-02-24 13:45:20 -05:00
parent 1b4dbe8894
commit 10d4ad98d9
3 changed files with 20 additions and 0 deletions

View File

@ -32,5 +32,12 @@ namespace MediaBrowser.Controller.Library
/// </summary>
/// <param name="path">The path.</param>
void ReportFileSystemChanged(string path);
/// <summary>
/// Determines whether [is path locked] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [is path locked] [the specified path]; otherwise, <c>false</c>.</returns>
bool IsPathLocked(string path);
}
}

View File

@ -64,6 +64,13 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
FileSize = new FileInfo(path).Length
};
if (_libraryMonitor.IsPathLocked(path))
{
result.Status = FileSortingStatus.Failure;
result.StatusMessage = "Path is locked by other processes. Please try again later.";
return result;
}
var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions();
var resolver = new Naming.TV.EpisodeResolver(namingOptions, new PatternsLogger());

View File

@ -78,6 +78,12 @@ namespace MediaBrowser.Server.Implementations.IO
TemporarilyIgnore(path);
}
public bool IsPathLocked(string path)
{
var lockedPaths = _tempIgnoredPaths.Keys.ToList();
return lockedPaths.Any(i => string.Equals(i, path, StringComparison.OrdinalIgnoreCase) || _fileSystem.ContainsSubPath(i, path));
}
public async void ReportFileSystemChangeComplete(string path, bool refreshPath)
{
if (string.IsNullOrEmpty(path))