Create missing series folders on disk scan (if enabled)

New: Option to create missing series folders during disk scans
pull/3113/head
Mark McDowall 11 years ago
parent fd70346ab0
commit ea36c6ed47

@ -37,6 +37,7 @@ namespace NzbDrone.Common
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 @@ namespace NzbDrone.Common
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

@ -282,6 +282,14 @@ namespace NzbDrone.Core.Configuration
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_"); }

@ -42,6 +42,7 @@ namespace NzbDrone.Core.Configuration
Boolean AutoRedownloadFailed { get; set; }
Boolean RemoveFailedDownloads { get; set; }
Boolean EnableFailedDownloadHandling { get; set; }
Boolean CreateEmptySeriesFolders { get; set; }
void SaveValues(Dictionary<string, object> configValues);
}
}

@ -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 @@ namespace NzbDrone.Core.MediaFiles
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 @@ namespace NzbDrone.Core.MediaFiles
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;
}

@ -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>

@ -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">

Loading…
Cancel
Save