1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-17 15:02:34 +02:00

Create missing series folders on disk scan (if enabled)

New: Option to create missing series folders during disk scans
This commit is contained in:
Mark McDowall 2013-11-18 22:25:02 -08:00
parent fd70346ab0
commit ea36c6ed47
6 changed files with 63 additions and 5 deletions

View File

@ -37,6 +37,7 @@ public interface IDiskProvider
void FolderSetLastWriteTimeUtc(string path, DateTime dateTime);
bool IsFileLocked(string path);
string GetPathRoot(string path);
string GetParentFolder(string path);
void SetPermissions(string filename, WellKnownSidType accountSid, FileSystemRights rights, AccessControlType controlType);
bool IsParent(string parentPath, string childPath);
void SetFolderWriteTime(string path, DateTime time);
@ -366,6 +367,20 @@ public string GetPathRoot(string path)
return Path.GetPathRoot(path);
}
public string GetParentFolder(string path)
{
Ensure.That(() => path).IsValidPath();
var parent = Directory.GetParent(path);
if (parent == null)
{
return null;
}
return parent.FullName;
}
public void SetPermissions(string filename, WellKnownSidType accountSid, FileSystemRights rights, AccessControlType controlType)
{
try

View File

@ -282,6 +282,14 @@ public Boolean EnableFailedDownloadHandling
set { SetValue("EnableFailedDownloadHandling", value); }
}
public Boolean CreateEmptySeriesFolders
{
//TODO: only create if the parent folder exists (check first)
get { return GetValueBoolean("CreateEmptySeriesFolders", false); }
set { SetValue("CreateEmptySeriesFolders", value); }
}
public string DownloadClientWorkingFolders
{
get { return GetValue("DownloadClientWorkingFolders", "_UNPACK_|_FAILED_"); }

View File

@ -42,6 +42,7 @@ public interface IConfigService
Boolean AutoRedownloadFailed { get; set; }
Boolean RemoveFailedDownloads { get; set; }
Boolean EnableFailedDownloadHandling { get; set; }
Boolean CreateEmptySeriesFolders { get; set; }
void SaveValues(Dictionary<string, object> configValues);
}
}

View File

@ -2,6 +2,7 @@
using System.Linq;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.MediaFiles.Commands;
using NzbDrone.Core.MediaFiles.EpisodeImport;
@ -25,17 +26,21 @@ public class DiskScanService :
private readonly IMakeImportDecision _importDecisionMaker;
private readonly IImportApprovedEpisodes _importApprovedEpisodes;
private readonly ICommandExecutor _commandExecutor;
private readonly IConfigService _configService;
private readonly Logger _logger;
public DiskScanService(IDiskProvider diskProvider,
IMakeImportDecision importDecisionMaker,
IImportApprovedEpisodes importApprovedEpisodes,
ICommandExecutor commandExecutor, Logger logger)
ICommandExecutor commandExecutor,
IConfigService configService,
Logger logger)
{
_diskProvider = diskProvider;
_importDecisionMaker = importDecisionMaker;
_importApprovedEpisodes = importApprovedEpisodes;
_commandExecutor = commandExecutor;
_configService = configService;
_logger = logger;
}
@ -46,6 +51,14 @@ private void Scan(Series series)
if (!_diskProvider.FolderExists(series.Path))
{
if (_configService.CreateEmptySeriesFolders &&
_diskProvider.FolderExists(_diskProvider.GetParentFolder(series.Path)))
{
_logger.Debug("Creating missing series folder: {0}", series.Path);
_diskProvider.CreateFolder(series.Path);
return;
}
_logger.Debug("Series folder doesn't exist: {0}", series.Path);
return;
}

View File

@ -25,9 +25,9 @@
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-question-sign" title="Should NzbDrone download episodes for this series?"/>
</span>
<span class="help-inline-checkbox">
<i class="icon-question-sign" title="Should NzbDrone download episodes for this series?"/>
</span>
</div>
</div>

View File

@ -1,5 +1,26 @@
<fieldset>
<legend>Season Folder</legend>
<legend>Folders</legend>
<div class="control-group advanced-setting">
<label class="control-label">Create empty series folders</label>
<div class="controls">
<label class="checkbox toggle well">
<input type="checkbox" name="createEmptySeriesFolders"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-question-sign" title="Create missing series folders during disk scan"/>
</span>
</div>
</div>
<!--TODO: Remove this and move it to Add Series-->
<div class="control-group">