[FR] Customize location of RecycleBin #75

This commit is contained in:
bobokun 2021-12-30 19:17:05 -05:00
parent e2a7a378d8
commit e6a9e3c7f7
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671
2 changed files with 6 additions and 4 deletions

View file

@ -194,7 +194,7 @@ class Config:
self.cross_seed_dir = self.util.check_for_attribute(self.data, "cross_seed", parent="directory", var_type="path")
else:
self.cross_seed_dir = self.util.check_for_attribute(self.data, "cross_seed", parent="directory", default_is_none=True)
self.recycle_dir = os.path.join(self.remote_dir, '.RecycleBin')
self.recycle_dir = self.util.check_for_attribute(self.data, "recycle_bin", parent="directory", var_type="path", default=os.path.join(self.remote_dir, '.RecycleBin'))
else:
e = "Config Error: directory attribute not found"
self.notify(e, 'Config')

View file

@ -464,6 +464,7 @@ class Qbt:
continue
except Exception as e:
util.print_stacktrace()
self.config.notify(e, 'Remove Unregistered Torrents', False)
logger.error(f"Unknown Error: {e}")
if del_tor >= 1 or del_tor_cont >= 1:
if del_tor >= 1: print_line(f"{'Did not delete' if dry_run else 'Deleted'} {del_tor} .torrent{'s' if del_tor > 1 else ''} but not content files.", loglevel)
@ -639,13 +640,14 @@ class Qbt:
orphaned_parent_path = set()
remote_path = self.config.remote_dir
root_path = self.config.root_dir
recycle_path = self.config.recycle_dir
if (remote_path != root_path):
root_files = [os.path.join(path.replace(remote_path, root_path), name)
for path, subdirs, files in alive_it(os.walk(remote_path))
for name in files if os.path.join(remote_path, 'orphaned_data') not in path and os.path.join(remote_path, '.RecycleBin') not in path]
for name in files if os.path.join(remote_path, 'orphaned_data') not in path and recycle_path not in path]
else:
root_files = [os.path.join(path, name) for path, subdirs, files in alive_it(os.walk(root_path))
for name in files if os.path.join(root_path, 'orphaned_data') not in path and os.path.join(root_path, '.RecycleBin') not in path]
for name in files if os.path.join(root_path, 'orphaned_data') not in path and recycle_path not in path]
# Get an updated list of torrents
torrent_list = self.get_torrents({'sort': 'added_on'})
@ -714,7 +716,7 @@ class Qbt:
except NotFound404Error:
return
# Create recycle bin if not exists
recycle_path = os.path.join(self.config.remote_dir, '.RecycleBin')
recycle_path = self.config.recycle_dir
os.makedirs(recycle_path, exist_ok=True)
separator(f"Moving {len(tor_files)} files to RecycleBin", space=False, border=False, loglevel='DEBUG')