From a1a1ee68f1f7af63a697c5236178c9fc51ca21cd Mon Sep 17 00:00:00 2001 From: Halali Date: Tue, 26 Mar 2019 20:49:03 +0100 Subject: [PATCH] Add Enable chmod setting --- bazarr/config.py | 1 + bazarr/get_subtitle.py | 4 ++-- bazarr/main.py | 6 ++++++ views/settings.tpl | 39 ++++++++++++++++++++++++++++++++++++--- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/bazarr/config.py b/bazarr/config.py index 5f7684b03..2d3405f04 100644 --- a/bazarr/config.py +++ b/bazarr/config.py @@ -35,6 +35,7 @@ defaults = { 'enabled_providers': '', 'throtteled_providers': '{}', 'multithreading': 'True', + 'chmod_enabled': 'False', 'chmod': '0640', 'subfolder': 'current', 'subfolder_custom': '', diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index e7a412a9c..9b2f13c82 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -170,7 +170,7 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName, try: fld = get_target_folder(path) - chmod = int(settings.general.chmod, 8) if not sys.platform.startswith('win') else None + chmod = int(settings.general.chmod, 8) if not sys.platform.startswith('win') and settings.general.getboolean('chmod_enabled') else None saved_subtitles = save_subtitles(video.original_path, subtitles, single=single, tags=None, # fixme directory=fld, @@ -361,7 +361,7 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a try: score = round(subtitle.score / max_score * 100, 2) fld = get_target_folder(path) - chmod = int(settings.general.chmod, 8) if not sys.platform.startswith('win') else None + chmod = int(settings.general.chmod, 8) if not sys.platform.startswith('win') and settings.general.getboolean('chmod_enabled') else None saved_subtitles = save_subtitles(video.original_path, [subtitle], single=single, tags=None, # fixme directory=fld, diff --git a/bazarr/main.py b/bazarr/main.py index a220af46d..78a2587ad 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -1197,6 +1197,11 @@ def save_settings(): settings_general_debug = 'False' else: settings_general_debug = 'True' + settings_general_chmod_enabled = request.forms.get('settings_general_chmod_enabled') + if settings_general_chmod_enabled is None: + settings_general_chmod_enabled = 'False' + else: + settings_general_chmod_enabled = 'True' settings_general_chmod = request.forms.get('settings_general_chmod') settings_general_sourcepath = request.forms.getall('settings_general_sourcepath') settings_general_destpath = request.forms.getall('settings_general_destpath') @@ -1283,6 +1288,7 @@ def save_settings(): settings.general.base_url = text_type(settings_general_baseurl) settings.general.path_mappings = text_type(settings_general_pathmapping) settings.general.debug = text_type(settings_general_debug) + settings.general.chmod_enabled = text_type(settings_general_chmod_enabled) settings.general.chmod = text_type(settings_general_chmod) settings.general.branch = text_type(settings_general_branch) settings.general.auto_update = text_type(settings_general_automatic) diff --git a/views/settings.tpl b/views/settings.tpl index da112d288..29072aeff 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -152,6 +152,17 @@ +
+
+ +
+
+
+ + +
+
+
@@ -599,7 +610,7 @@
-
+
@@ -610,7 +621,7 @@
-
+
@@ -2032,6 +2043,7 @@ % import sys % if sys.platform.startswith('win'): $("#chmod").hide(); + $("#chmod_enabled").hide(); % end $('.menu .item') @@ -2070,6 +2082,12 @@ $("#settings_debug").checkbox('uncheck'); } + if ($('#settings_chmod_enabled').data("chmod") === "True") { + $("#settings_chmod_enabled").checkbox('check'); + } else { + $("#settings_chmod_enabled").checkbox('uncheck'); + } + if ($('#settings_single_language').data("single-language") === "True") { $("#settings_single_language").checkbox('check'); } else { @@ -2247,6 +2265,21 @@ } }); + if ($('#settings_chmod_enabled').data("chmod") === "True") { + $('#chmod').show(); + } else { + $('#chmod').hide(); + } + + $('#settings_chmod_enabled').checkbox({ + onChecked: function() { + $('#chmod').show(); + }, + onUnchecked: function() { + $('#chmod').hide(); + } + }); + if ($('#settings_auth_type').val() === "None") { $('.auth_option').hide(); } @@ -2467,7 +2500,7 @@ } ] }, - % if not sys.platform.startswith('win'): + % if not sys.platform.startswith('win') and settings.general.getboolean('chmod_enabled'): settings_general_chmod: { rules: [ {