Skip to content

Commit

Permalink
fix: make ignore pattern repeatable
Browse files Browse the repository at this point in the history
  • Loading branch information
onedr0p authored Aug 23, 2023
1 parent 7d0c615 commit 2900b0e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions qbittools/commands/orphaned.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
def __init__(args, logger):
client = qbittools.qbit_client(args)
completed_dir = str(qbittools.config.save_path)
ignore_patterns = ' '.join(args.ignore_patterns)
ignore_patterns = [item for sublist in args.ignore_pattern for item in sublist]

torrent_list = client.torrents.info()
completed_dir_list = completed_dir.split(os.sep)

logger.info(f"Checking for orphaned files in qBittorrent")
logger.info(f"Not deleting files in {completed_dir} that are in qBittorrent")
logger.info(f"Use --confirm to delete files in {completed_dir} that are not in qBittorrent")
logger.info(f"Ignoring file/folder patterns '{ignore_patterns}'")
logger.info(f"Ignoring file/folder patterns '{' '.join(ignore_patterns)}'")

logger.info(f"Getting a list of all torrents 'content_path' in qBittorrent")
qbittorrent_items = set()
Expand All @@ -42,7 +42,7 @@ def __init__(args, logger):
contents = os.listdir(folder_path)
for item in contents:
item_path = os.path.join(folder_path, item)
if not any(fnmatch(item, pattern) or fnmatch(item_path, pattern) for pattern in ignore_patterns.split()):
if not any(fnmatch(item, pattern) or fnmatch(item_path, pattern) for pattern in ignore_patterns):
if item_path not in qbittorrent_items:
if not args.confirm:
logger.info(f"Skipping deletion of {item_path}")
Expand All @@ -66,5 +66,5 @@ def __init__(args, logger):
def add_arguments(subparser):
parser = subparser.add_parser('orphaned')
parser.add_argument('--confirm', action='store_true', help='Confirm deletion of orphaned files', required=False)
parser.add_argument('-i', '--ignore-patterns', nargs='*', metavar='mypattern', default=[], help='Ignore patterns, split by a whitespace', required=False)
parser.add_argument('--ignore-pattern', nargs='*', action='append', metavar='mypattern', default=[], help='Ignore pattern, can be repeated multiple times', required=False)
qbittools.add_default_args(parser)

0 comments on commit 2900b0e

Please sign in to comment.