diff --git a/server/RdtClient.Data/Models/Internal/DbSettings.cs b/server/RdtClient.Data/Models/Internal/DbSettings.cs index f3e3046..0bc712c 100644 --- a/server/RdtClient.Data/Models/Internal/DbSettings.cs +++ b/server/RdtClient.Data/Models/Internal/DbSettings.cs @@ -165,6 +165,14 @@ public class DbSettingsWatch [Description("Watch this path for .torrent or .magnet files. When a file is found it will be automatically imported.")] public String? Path { get; set; } = null; + [DisplayName("Error Path")] + [Description("When an error occurs the torrent file is moved to this directory. When unset it will be moved to /error in the watchpath.")] + public String? ErrorPath { get; set; } = null; + + [DisplayName("Processed Path")] + [Description("When a torrent file is added succesfully it will be moved to this directory. When unset it will be moved to /processed in the watchpath.")] + public String? ProcessedPath { get; set; } = null; + [DisplayName("Check Interval")] [Description("Time in seconds to check the folder for new files.")] public Int32 Interval { get; set; } = 60; diff --git a/server/RdtClient.Service/BackgroundServices/WatchFolderChecker.cs b/server/RdtClient.Service/BackgroundServices/WatchFolderChecker.cs index 4ac29ed..1d0265d 100644 --- a/server/RdtClient.Service/BackgroundServices/WatchFolderChecker.cs +++ b/server/RdtClient.Service/BackgroundServices/WatchFolderChecker.cs @@ -47,9 +47,14 @@ 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)) + if (!String.IsNullOrWhiteSpace(Settings.Get.Watch.ProcessedPath)) { - Directory.CreateDirectory(processedStorePath); + processedStorePath = Settings.Get.Watch.ProcessedPath; + } + + if (!String.IsNullOrWhiteSpace(Settings.Get.Watch.ErrorPath)) + { + errorStorePath = Settings.Get.Watch.ErrorPath; } var nextCheck = _prevCheck.AddSeconds(Settings.Get.Watch.Interval); @@ -109,6 +114,12 @@ public class WatchFolderChecker : BackgroundService } var processedPath = Path.Combine(processedStorePath, fileInfo.Name); + + if (!Directory.Exists(processedStorePath)) + { + Directory.CreateDirectory(processedStorePath); + } + File.Move(torrentFile, processedPath); _logger.Log(LogLevel.Debug, "Moved {torrentFile} to {processedPath}", torrentFile, processedPath);