EpisodeFileOrganizer: Improve error handling (alternate approach)

Previously some methods were just returning null or empty values in case
of encountered errors; as a consequence, the actual reason for failure
was never written to the auto-organize log.
Instead, only a generic message like "Unable to sort xxx because target
path could not be determined." was displayed.

After this change, the actual reason for failure will be saved to the
auto-organize log or displayed in the UI (when completing the organize
dialog).

This information is very important for the user. Examples are "No
permission", "Target folder not available", "Disk full", etc..
This commit is contained in:
softworkz
2016-08-18 22:05:54 +02:00
parent 325a3cc844
commit 66a80ac6b9
3 changed files with 48 additions and 18 deletions

View File

@@ -112,8 +112,13 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
var organizer = new EpisodeFileOrganizer(this, _config, _fileSystem, _logger, _libraryManager,
_libraryMonitor, _providerManager);
await organizer.OrganizeEpisodeFile(result.OriginalPath, GetAutoOrganizeOptions(), true, CancellationToken.None)
var organizeResult = await organizer.OrganizeEpisodeFile(result.OriginalPath, GetAutoOrganizeOptions(), true, CancellationToken.None)
.ConfigureAwait(false);
if (organizeResult.Status != FileSortingStatus.Success)
{
throw new Exception(result.StatusMessage);
}
}
public Task ClearLog()
@@ -126,7 +131,12 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
var organizer = new EpisodeFileOrganizer(this, _config, _fileSystem, _logger, _libraryManager,
_libraryMonitor, _providerManager);
await organizer.OrganizeWithCorrection(request, GetAutoOrganizeOptions(), CancellationToken.None).ConfigureAwait(false);
var result = await organizer.OrganizeWithCorrection(request, GetAutoOrganizeOptions(), CancellationToken.None).ConfigureAwait(false);
if (result.Status != FileSortingStatus.Success)
{
throw new Exception(result.StatusMessage);
}
}
public QueryResult<SmartMatchInfo> GetSmartMatchInfos(FileOrganizationResultQuery query)