From f54112a15cf2432a71412a83e16b45523b4cd6be Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 6 Dec 2021 10:15:49 +0000 Subject: [PATCH] Use a single function for resetting theme designer changes --- daemon.py | 1 + theme.py | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/daemon.py b/daemon.py index dc1f274bb..8b2f7764f 100644 --- a/daemon.py +++ b/daemon.py @@ -2204,6 +2204,7 @@ class PubServer(BaseHTTPRequestHandler): allowLocalNetworkAccess, systemLanguage) + # set boolean values if 'rss-icon-at-top' in themeDesignerParams: if themeDesignerParams['rss-icon-at-top'].lower() == 'true': self.server.rssIconAtTop = True diff --git a/theme.py b/theme.py index 25ec9407e..9b34280ae 100644 --- a/theme.py +++ b/theme.py @@ -516,6 +516,10 @@ def resetThemeDesignerSettings(baseDir: str, themeName: str, domain: str, setTheme(baseDir, themeName, domain, allowLocalNetworkAccess, systemLanguage) + customIconsDir = baseDir + '/accounts/customIcons' + if os.path.isdir(customIconsDir): + rmtree(customIconsDir, ignore_errors=False, onerror=None) + def _readVariablesFile(baseDir: str, themeName: str, variablesFile: str, @@ -826,13 +830,9 @@ def setTheme(baseDir: str, name: str, domain: str, # if the theme has changed then remove any custom settings if prevThemeName != name: - customVariablesFile = baseDir + '/accounts/theme.json' - if os.path.isfile(customVariablesFile): - print('Removing theme designer settings') - try: - os.remove(customVariablesFile) - except OSError: - print('EX: removing theme designer settings') + resetThemeDesignerSettings(baseDir, name, domain, + allowLocalNetworkAccess, + systemLanguage) _removeTheme(baseDir)