2011-10-22 19:31:28 -07:00
|
|
|
using System;
|
|
|
|
using NLog;
|
|
|
|
using Ninject;
|
2011-11-12 20:07:06 -08:00
|
|
|
using NzbDrone.Common;
|
2011-06-07 14:19:11 -07:00
|
|
|
using NzbDrone.Core.Model.Notification;
|
2011-10-22 19:31:28 -07:00
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-06-06 23:29:07 -07:00
|
|
|
|
2011-06-07 14:19:11 -07:00
|
|
|
namespace NzbDrone.Core.Providers.Jobs
|
2011-06-06 23:29:07 -07:00
|
|
|
{
|
2011-06-07 14:19:11 -07:00
|
|
|
public class PostDownloadScanJob : IJob
|
2011-06-06 23:29:07 -07:00
|
|
|
{
|
2011-10-22 19:31:28 -07:00
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
2011-10-12 16:47:28 -07:00
|
|
|
private readonly PostDownloadProvider _postDownloadProvider;
|
2011-10-22 19:31:28 -07:00
|
|
|
private readonly ConfigProvider _configProvider;
|
|
|
|
private readonly DiskProvider _diskProvider;
|
2011-06-06 23:29:07 -07:00
|
|
|
|
2011-06-13 18:23:04 -07:00
|
|
|
[Inject]
|
2011-10-22 19:31:28 -07:00
|
|
|
public PostDownloadScanJob(PostDownloadProvider postDownloadProvider,ConfigProvider configProvider, DiskProvider diskProvider)
|
2011-06-06 23:29:07 -07:00
|
|
|
{
|
2011-10-12 16:47:28 -07:00
|
|
|
_postDownloadProvider = postDownloadProvider;
|
2011-10-22 19:31:28 -07:00
|
|
|
_configProvider = configProvider;
|
|
|
|
_diskProvider = diskProvider;
|
2011-06-06 23:29:07 -07:00
|
|
|
}
|
|
|
|
|
2011-06-07 14:19:11 -07:00
|
|
|
public PostDownloadScanJob()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
{
|
2011-07-04 23:52:06 -07:00
|
|
|
get { return "Drop folder monitor"; }
|
2011-06-07 14:19:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public int DefaultInterval
|
|
|
|
{
|
|
|
|
get { return 1; }
|
|
|
|
}
|
2011-06-06 23:29:07 -07:00
|
|
|
|
2011-08-21 17:48:37 -07:00
|
|
|
public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
2011-06-06 23:29:07 -07:00
|
|
|
{
|
2011-10-22 19:31:28 -07:00
|
|
|
var dropFolder = _configProvider.SabDropDirectory;
|
|
|
|
|
|
|
|
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-06 23:29:07 -07:00
|
|
|
}
|
|
|
|
}
|
2011-08-25 23:23:21 -07:00
|
|
|
}
|