improve cancellation support of auto-organize

This commit is contained in:
Luke Pulverenti
2017-03-29 15:16:43 -04:00
parent cb5c9333c5
commit f641c501a7
10 changed files with 49 additions and 27 deletions

View File

@@ -72,17 +72,24 @@ namespace Emby.Server.Implementations.FileOrganization
foreach (var file in eligibleFiles)
{
cancellationToken.ThrowIfCancellationRequested();
var organizer = new EpisodeFileOrganizer(_organizationService, _config, _fileSystem, _logger, _libraryManager,
_libraryMonitor, _providerManager);
try
{
var result = await organizer.OrganizeEpisodeFile(file.FullName, options, options.TvOptions.OverwriteExistingEpisodes, cancellationToken).ConfigureAwait(false);
if (result.Status == FileSortingStatus.Success && !processedFolders.Contains(file.DirectoryName, StringComparer.OrdinalIgnoreCase))
{
processedFolders.Add(file.DirectoryName);
}
}
catch (OperationCanceledException)
{
break;
}
catch (Exception ex)
{
_logger.ErrorException("Error organizing episode {0}", ex, file.FullName);