You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.0 KiB
38 lines
1.0 KiB
using NLog;
|
|
using NzbDrone.Common.Disk;
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
|
{
|
|
public class NotInUseSpecification : IImportDecisionEngineSpecification
|
|
{
|
|
private readonly IDiskProvider _diskProvider;
|
|
private readonly Logger _logger;
|
|
|
|
public NotInUseSpecification(IDiskProvider diskProvider, Logger logger)
|
|
{
|
|
_diskProvider = diskProvider;
|
|
_logger = logger;
|
|
}
|
|
|
|
public string RejectionReason { get { return "File is in use"; } }
|
|
|
|
public bool IsSatisfiedBy(LocalEpisode localEpisode)
|
|
{
|
|
if (localEpisode.ExistingFile)
|
|
{
|
|
_logger.Trace("{0} is in series folder, skipping in use check", localEpisode.Path);
|
|
return true;
|
|
}
|
|
|
|
if (_diskProvider.IsFileLocked(localEpisode.Path))
|
|
{
|
|
_logger.Trace("{0} is in use");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|