New: Explicit toggle for importing extra files

pull/6/head
Mark McDowall 8 years ago
parent db9d601115
commit 6aaefae2d5

@ -20,6 +20,7 @@ namespace NzbDrone.Api.Config
public bool SkipFreeSpaceCheckWhenImporting { get; set; }
public bool CopyUsingHardlinks { get; set; }
public bool ImportExtraFiles { get; set; }
public string ExtraFileExtensions { get; set; }
public bool EnableMediaInfo { get; set; }
}
@ -44,6 +45,7 @@ namespace NzbDrone.Api.Config
SkipFreeSpaceCheckWhenImporting = model.SkipFreeSpaceCheckWhenImporting,
CopyUsingHardlinks = model.CopyUsingHardlinks,
ImportExtraFiles = model.ImportExtraFiles,
ExtraFileExtensions = model.ExtraFileExtensions,
EnableMediaInfo = model.EnableMediaInfo
};

@ -203,6 +203,13 @@ namespace NzbDrone.Core.Configuration
set { SetValue("EnableMediaInfo", value); }
}
public bool ImportExtraFiles
{
get { return GetValueBoolean("ImportExtraFiles", false); }
set { SetValue("ImportExtraFiles", value); }
}
public string ExtraFileExtensions
{
get { return GetValue("ExtraFileExtensions", ""); }

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Common.Http.Proxy;
@ -32,6 +32,7 @@ namespace NzbDrone.Core.Configuration
bool SkipFreeSpaceCheckWhenImporting { get; set; }
bool CopyUsingHardlinks { get; set; }
bool EnableMediaInfo { get; set; }
bool ImportExtraFiles { get; set; }
string ExtraFileExtensions { get; set; }
//Permissions (Media Management)

@ -0,0 +1,44 @@
using System.Data;
using FluentMigrator;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(109)]
public class import_extra_files : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Execute.WithConnection(ImportExtraFiles);
}
private void ImportExtraFiles(IDbConnection conn, IDbTransaction tran)
{
using (var cmd = conn.CreateCommand())
{
cmd.Transaction = tran;
cmd.CommandText = "SELECT Value from Config WHERE Key = 'extrafileextensions'";
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
var value = reader.GetString(0);
if (value.IsNotNullOrWhiteSpace())
{
using (var insertCmd = conn.CreateCommand())
{
insertCmd.Transaction = tran;
insertCmd.CommandText = "INSERT INTO Config (Key, Value) VALUES('importextrafiles', 1)";
insertCmd.ExecuteNonQuery();
}
}
}
}
}
}
}
}

@ -57,6 +57,11 @@ namespace NzbDrone.Core.Extras
extraFileManager.CreateAfterEpisodeImport(series, episodeFile);
}
if (!_configService.ImportExtraFiles)
{
return;
}
var sourcePath = localEpisode.Path;
var sourceFolder = _diskProvider.GetParentFolder(sourcePath);
var sourceFileName = Path.GetFileNameWithoutExtension(sourcePath);

@ -248,6 +248,7 @@
<Compile Include="Datastore\Migration\068_add_release_restrictions.cs" />
<Compile Include="Datastore\Migration\069_quality_proper.cs" />
<Compile Include="Datastore\Migration\070_delay_profile.cs" />
<Compile Include="Datastore\Migration\109_import_extra_files.cs" />
<Compile Include="Datastore\Migration\108_fix_extra_file_extension.cs" />
<Compile Include="Datastore\Migration\107_remove_wombles.cs" />
<Compile Include="Datastore\Migration\106_update_btn_url.cs" />

@ -3,10 +3,37 @@ var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var view = Marionette.ItemView.extend({
template : 'Settings/MediaManagement/Sorting/SortingViewTemplate'
template : 'Settings/MediaManagement/Sorting/SortingViewTemplate',
events : {
'change .x-import-extra-files' : '_setExtraFileExtensionVisibility'
},
ui : {
importExtraFiles : '.x-import-extra-files',
extraFileExtensions : '.x-extra-file-extensions'
},
onRender : function() {
if (!this.ui.importExtraFiles.prop('checked')) {
this.ui.extraFileExtensions.hide();
}
},
_setExtraFileExtensionVisibility : function() {
var showExtraFileExtensions = this.ui.importExtraFiles.prop('checked');
if (showExtraFileExtensions) {
this.ui.extraFileExtensions.slideDown();
}
else {
this.ui.extraFileExtensions.slideUp();
}
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
module.exports = view;
module.exports = view;

@ -80,6 +80,29 @@
<div class="form-group">
<label class="col-sm-3 control-label">Import Extra Files</label>
<div class="col-sm-9">
<div class="input-group">
<label class="checkbox toggle well">
<input type="checkbox" name="importExtraFiles" class="x-import-extra-files"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-sonarr-form-info" title="Import matching extra files (subtitles, nfo, etc) after importing an episode file"/>
</span>
</div>
</div>
</div>
<div class="form-group x-extra-file-extensions">
<label class="col-sm-3 control-label">Extra File Extensions</label>
<div class="col-sm-1 col-sm-push-5 help-inline">
<i class="icon-sonarr-form-info" title="Comma separated list of extra files to import, ie sub,nfo (.nfo will be imported as .nfo-orig)"/>
</div>

Loading…
Cancel
Save