WIP: change default data directories, subdirectories and config file

This commit is contained in:
caryoscelus 2024-05-07 14:03:44 +00:00
parent e8da744744
commit bdddf58712
No known key found for this signature in database
GPG key ID: 254EDDB85B66CB1F
27 changed files with 263 additions and 121 deletions

View file

@ -14,7 +14,7 @@ from util import helper
class ContentFilterStorage(object):
def __init__(self, site_manager):
self.log = logging.getLogger("ContentFilterStorage")
self.file_path = "%s/filters.json" % config.data_dir
self.file_path = config.config_dir / 'filters.json'
self.site_manager = site_manager
self.file_content = self.load()
@ -36,12 +36,12 @@ class ContentFilterStorage(object):
def load(self):
# Rename previously used mutes.json -> filters.json
if os.path.isfile("%s/mutes.json" % config.data_dir):
if (config.config_dir / 'mutes.json').is_file():
self.log.info("Renaming mutes.json to filters.json...")
os.rename("%s/mutes.json" % config.data_dir, self.file_path)
if os.path.isfile(self.file_path):
os.rename(config.config_dir / 'mutes.json', self.file_path)
if self.file_path.is_file():
try:
return json.load(open(self.file_path))
return json.load(self.file_path.open())
except Exception as err:
self.log.error("Error loading filters.json: %s" % err)
return None