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 errorStorePath = Path.Combine(Settings.Get.Watch.Path, "error");
if (!Directory.Exists(processedStorePath))
{
@ -76,13 +77,17 @@ public class WatchFolderChecker : BackgroundService
continue;
}
try
{
_logger.Log(LogLevel.Debug, "Processing {torrentFile}", torrentFile);
var torrent = new Torrent
{
Category = Settings.Get.Watch.Default.Category,
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,
DownloadMinSize = Settings.Get.Watch.Default.MinFileSize,
TorrentRetryAttempts = Settings.Get.Watch.Default.TorrentRetryAttempts,
@ -108,6 +113,17 @@ public class WatchFolderChecker : BackgroundService
_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)
{