2011-12-02 02:33:17 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System;
|
2011-10-23 04:31:28 +02:00
|
|
|
|
using NLog;
|
2011-11-13 05:07:06 +01:00
|
|
|
|
using NzbDrone.Common;
|
2011-06-07 23:19:11 +02:00
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
2011-12-02 02:33:17 +01:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2011-10-23 04:31:28 +02:00
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-06-07 08:29:07 +02:00
|
|
|
|
|
2011-12-02 02:33:17 +01:00
|
|
|
|
namespace NzbDrone.Core.Jobs
|
2011-06-07 08:29:07 +02:00
|
|
|
|
{
|
2011-06-07 23:19:11 +02:00
|
|
|
|
public class PostDownloadScanJob : IJob
|
2011-06-07 08:29:07 +02:00
|
|
|
|
{
|
2011-10-23 04:31:28 +02:00
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
2011-10-13 01:47:28 +02:00
|
|
|
|
private readonly PostDownloadProvider _postDownloadProvider;
|
2011-10-23 04:31:28 +02:00
|
|
|
|
private readonly ConfigProvider _configProvider;
|
|
|
|
|
private readonly DiskProvider _diskProvider;
|
2011-06-07 08:29:07 +02:00
|
|
|
|
|
2011-10-23 04:31:28 +02:00
|
|
|
|
public PostDownloadScanJob(PostDownloadProvider postDownloadProvider,ConfigProvider configProvider, DiskProvider diskProvider)
|
2011-06-07 08:29:07 +02:00
|
|
|
|
{
|
2011-10-13 01:47:28 +02:00
|
|
|
|
_postDownloadProvider = postDownloadProvider;
|
2011-10-23 04:31:28 +02:00
|
|
|
|
_configProvider = configProvider;
|
|
|
|
|
_diskProvider = diskProvider;
|
2011-06-07 08:29:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-07 23:19:11 +02:00
|
|
|
|
public PostDownloadScanJob()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
2011-07-05 08:52:06 +02:00
|
|
|
|
get { return "Drop folder monitor"; }
|
2011-06-07 23:19:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-01-15 03:47:23 +01:00
|
|
|
|
public TimeSpan DefaultInterval
|
2011-06-07 23:19:11 +02:00
|
|
|
|
{
|
2012-01-15 03:47:23 +01:00
|
|
|
|
get { return TimeSpan.FromMinutes(1); }
|
2011-06-07 23:19:11 +02:00
|
|
|
|
}
|
2011-06-07 08:29:07 +02:00
|
|
|
|
|
2012-09-10 21:04:17 +02:00
|
|
|
|
public virtual void Start(ProgressNotification notification, dynamic options)
|
2011-06-07 08:29:07 +02:00
|
|
|
|
{
|
2012-09-23 08:01:31 +02:00
|
|
|
|
string dropFolder;
|
|
|
|
|
|
|
|
|
|
if (options != null && !String.IsNullOrWhiteSpace(options.Path))
|
|
|
|
|
dropFolder = options.Path;
|
|
|
|
|
|
|
|
|
|
else
|
2012-11-23 03:56:27 +01:00
|
|
|
|
dropFolder = _configProvider.DownloadClientTvDirectory;
|
2011-10-23 04:31:28 +02:00
|
|
|
|
|
|
|
|
|
if (String.IsNullOrWhiteSpace(dropFolder))
|
|
|
|
|
{
|
|
|
|
|
Logger.Debug("No drop folder is defined. Skipping.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_diskProvider.FolderExists(dropFolder))
|
|
|
|
|
{
|
|
|
|
|
Logger.Warn("Unable to Scan for New Downloads - folder Doesn't exist: [{0}]", dropFolder);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_postDownloadProvider.ProcessDropFolder(dropFolder);
|
2011-06-07 08:29:07 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-08-26 08:23:21 +02:00
|
|
|
|
}
|