diff --git a/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs b/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs index 097ecc693..fb6ef94e5 100644 --- a/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs +++ b/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs @@ -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 }; diff --git a/src/NzbDrone.Core/Configuration/ConfigService.cs b/src/NzbDrone.Core/Configuration/ConfigService.cs index 8563e1eb1..06f7c3006 100644 --- a/src/NzbDrone.Core/Configuration/ConfigService.cs +++ b/src/NzbDrone.Core/Configuration/ConfigService.cs @@ -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", ""); } diff --git a/src/NzbDrone.Core/Configuration/IConfigService.cs b/src/NzbDrone.Core/Configuration/IConfigService.cs index e17d8d6dc..589e003e1 100644 --- a/src/NzbDrone.Core/Configuration/IConfigService.cs +++ b/src/NzbDrone.Core/Configuration/IConfigService.cs @@ -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) diff --git a/src/NzbDrone.Core/Datastore/Migration/109_import_extra_files.cs b/src/NzbDrone.Core/Datastore/Migration/109_import_extra_files.cs new file mode 100644 index 000000000..03bf220ee --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/109_import_extra_files.cs @@ -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(); + } + } + } + } + } + } + } +} diff --git a/src/NzbDrone.Core/Extras/ExtraService.cs b/src/NzbDrone.Core/Extras/ExtraService.cs index d35dcef15..811d3ebea 100644 --- a/src/NzbDrone.Core/Extras/ExtraService.cs +++ b/src/NzbDrone.Core/Extras/ExtraService.cs @@ -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); diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 932dd485c..ee6f77d07 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -248,6 +248,7 @@ + diff --git a/src/UI/Settings/MediaManagement/Sorting/SortingView.js b/src/UI/Settings/MediaManagement/Sorting/SortingView.js index f339f9dea..9194f895e 100644 --- a/src/UI/Settings/MediaManagement/Sorting/SortingView.js +++ b/src/UI/Settings/MediaManagement/Sorting/SortingView.js @@ -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; \ No newline at end of file +module.exports = view; diff --git a/src/UI/Settings/MediaManagement/Sorting/SortingViewTemplate.hbs b/src/UI/Settings/MediaManagement/Sorting/SortingViewTemplate.hbs index a6b26d353..0e37e2a95 100644 --- a/src/UI/Settings/MediaManagement/Sorting/SortingViewTemplate.hbs +++ b/src/UI/Settings/MediaManagement/Sorting/SortingViewTemplate.hbs @@ -80,6 +80,29 @@
+
+
+
+
+ +
+ +