Move watch files to the error folder when there is an error.

This commit is contained in:
Roger Far 2022-10-18 12:13:02 -06:00
parent 187a428ba7
commit 297216dea5

View file

@ -45,6 +45,7 @@ public class WatchFolderChecker : BackgroundService
} }
var processedStorePath = Path.Combine(Settings.Get.Watch.Path, "processed"); var processedStorePath = Path.Combine(Settings.Get.Watch.Path, "processed");
var errorStorePath = Path.Combine(Settings.Get.Watch.Path, "error");
if (!Directory.Exists(processedStorePath)) if (!Directory.Exists(processedStorePath))
{ {
@ -76,13 +77,17 @@ public class WatchFolderChecker : BackgroundService
continue; continue;
} }
try
{
_logger.Log(LogLevel.Debug, "Processing {torrentFile}", torrentFile); _logger.Log(LogLevel.Debug, "Processing {torrentFile}", torrentFile);
var torrent = new Torrent var torrent = new Torrent
{ {
Category = Settings.Get.Watch.Default.Category, Category = Settings.Get.Watch.Default.Category,
HostDownloadAction = Settings.Get.Watch.Default.HostDownloadAction, HostDownloadAction = Settings.Get.Watch.Default.HostDownloadAction,
DownloadAction = Settings.Get.Watch.Default.OnlyDownloadAvailableFiles ? TorrentDownloadAction.DownloadAvailableFiles : TorrentDownloadAction.DownloadAll, DownloadAction = Settings.Get.Watch.Default.OnlyDownloadAvailableFiles
? TorrentDownloadAction.DownloadAvailableFiles
: TorrentDownloadAction.DownloadAll,
FinishedAction = Settings.Get.Watch.Default.FinishedAction, FinishedAction = Settings.Get.Watch.Default.FinishedAction,
DownloadMinSize = Settings.Get.Watch.Default.MinFileSize, DownloadMinSize = Settings.Get.Watch.Default.MinFileSize,
TorrentRetryAttempts = Settings.Get.Watch.Default.TorrentRetryAttempts, TorrentRetryAttempts = Settings.Get.Watch.Default.TorrentRetryAttempts,
@ -108,6 +113,17 @@ public class WatchFolderChecker : BackgroundService
_logger.Log(LogLevel.Debug, "Moved {torrentFile} to {processedPath}", torrentFile, processedPath); _logger.Log(LogLevel.Debug, "Moved {torrentFile} to {processedPath}", torrentFile, processedPath);
} }
catch
{
if (!Directory.Exists(errorStorePath))
{
Directory.CreateDirectory(errorStorePath);
}
var processedPath = Path.Combine(errorStorePath, fileInfo.Name);
File.Move(torrentFile, processedPath);
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {