2011-12-02 01:33:17 +00:00
|
|
|
using System;
|
2013-03-05 05:37:33 +00:00
|
|
|
using System.Linq;
|
2011-10-23 02:31:28 +00:00
|
|
|
using NLog;
|
2011-11-13 04:07:06 +00:00
|
|
|
using NzbDrone.Common;
|
2013-02-24 06:48:52 +00:00
|
|
|
using NzbDrone.Core.Configuration;
|
2011-06-07 21:19:11 +00:00
|
|
|
using NzbDrone.Core.Model.Notification;
|
2011-12-02 01:33:17 +00:00
|
|
|
using NzbDrone.Core.Providers;
|
2011-06-07 06:29:07 +00:00
|
|
|
|
2013-03-05 05:37:33 +00:00
|
|
|
namespace NzbDrone.Core.Jobs.Implementations
|
2011-06-07 06:29:07 +00:00
|
|
|
{
|
2011-06-07 21:19:11 +00:00
|
|
|
public class PostDownloadScanJob : IJob
|
2011-06-07 06:29:07 +00:00
|
|
|
{
|
2011-10-23 02:31:28 +00:00
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
2013-04-15 01:41:39 +00:00
|
|
|
private readonly DropFolderImportService _dropFolderImportService;
|
2013-02-24 06:48:52 +00:00
|
|
|
private readonly IConfigService _configService;
|
2011-10-23 02:31:28 +00:00
|
|
|
private readonly DiskProvider _diskProvider;
|
2011-06-07 06:29:07 +00:00
|
|
|
|
2013-04-15 01:41:39 +00:00
|
|
|
public PostDownloadScanJob(DropFolderImportService dropFolderImportService,IConfigService configService, DiskProvider diskProvider)
|
2011-06-07 06:29:07 +00:00
|
|
|
{
|
2013-04-15 01:41:39 +00:00
|
|
|
_dropFolderImportService = dropFolderImportService;
|
2013-02-24 06:48:52 +00:00
|
|
|
_configService = configService;
|
2011-10-23 02:31:28 +00:00
|
|
|
_diskProvider = diskProvider;
|
2011-06-07 06:29:07 +00:00
|
|
|
}
|
|
|
|
|
2011-06-07 21:19:11 +00:00
|
|
|
public PostDownloadScanJob()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
{
|
2011-07-05 06:52:06 +00:00
|
|
|
get { return "Drop folder monitor"; }
|
2011-06-07 21:19:11 +00:00
|
|
|
}
|
|
|
|
|
2012-01-15 02:47:23 +00:00
|
|
|
public TimeSpan DefaultInterval
|
2011-06-07 21:19:11 +00:00
|
|
|
{
|
2012-01-15 02:47:23 +00:00
|
|
|
get { return TimeSpan.FromMinutes(1); }
|
2011-06-07 21:19:11 +00:00
|
|
|
}
|
2011-06-07 06:29:07 +00:00
|
|
|
|
2012-09-10 19:04:17 +00:00
|
|
|
public virtual void Start(ProgressNotification notification, dynamic options)
|
2011-06-07 06:29:07 +00:00
|
|
|
{
|
2012-09-23 06:01:31 +00:00
|
|
|
string dropFolder;
|
|
|
|
|
|
|
|
if (options != null && !String.IsNullOrWhiteSpace(options.Path))
|
|
|
|
dropFolder = options.Path;
|
|
|
|
|
|
|
|
else
|
2013-02-24 06:48:52 +00:00
|
|
|
dropFolder = _configService.DownloadClientTvDirectory;
|
2011-10-23 02:31:28 +00: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;
|
|
|
|
}
|
|
|
|
|
2013-04-15 01:41:39 +00:00
|
|
|
_dropFolderImportService.ProcessDropFolder(dropFolder);
|
2011-06-07 06:29:07 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-26 06:23:21 +00:00
|
|
|
}
|