1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 10:32:35 +01:00
Radarr/NzbDrone.Core/Jobs/PostDownloadScanJob.cs

66 lines
1.9 KiB
C#
Raw Normal View History

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