bug fix: empty recyclebin dir causing error

This commit is contained in:
bobokun 2022-01-26 08:41:31 -05:00
parent a4fbf2a582
commit 8d6fb140b9
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671
2 changed files with 3 additions and 3 deletions

View file

@ -200,7 +200,7 @@ class Config:
else:
self.cross_seed_dir = self.util.check_for_attribute(self.data, "cross_seed", parent="directory", default_is_none=True)
if self.recyclebin['enabled']:
if "recycle_bin" in self.data["directory"]:
if "recycle_bin" in self.data["directory"] and self.data["directory"]["recycle_bin"] is not None:
default_recycle = os.path.join(self.remote_dir, os.path.basename(self.data['directory']['recycle_bin'].rstrip('/')))
else:
default_recycle = os.path.join(self.remote_dir, '.RecycleBin')

View file

@ -59,7 +59,7 @@ class check:
else:
text = f"{parent} sub-attribute {attribute}"
if data is None or attribute not in data:
if data is None or attribute not in data or (attribute in data and data[attribute] is None and not default_is_none):
message = f"{text} not found"
if parent and save is True:
loaded_config, _, _ = yaml.util.load_yaml_guess_indent(open(self.config.config_path))
@ -77,7 +77,7 @@ class check:
endline = f"\n{parent} sub-attribute {attribute} added to config"
if parent not in loaded_config or not loaded_config[parent]:
loaded_config[parent] = {attribute: default}
elif attribute not in loaded_config[parent]:
elif attribute not in loaded_config[parent] or (attribute in loaded_config[parent] and loaded_config[parent][attribute] is None):
loaded_config[parent][attribute] = default
else:
endline = ""