Skip to content

Commit d17f3e5

Browse files
committed
pdm dedupe
1 parent 4049789 commit d17f3e5

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

pdm.lock

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xklb/media/dedupe.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import argparse, os, re, tempfile
1+
import argparse, os, re, shlex, tempfile
22
from collections import defaultdict
33
from concurrent.futures import ThreadPoolExecutor
44
from copy import deepcopy
@@ -10,7 +10,7 @@
1010
from xklb import db_media, usage
1111
from xklb.media import media_printer
1212
from xklb.scripts import sample_compare, sample_hash
13-
from xklb.utils import consts, db_utils, devices, file_utils, iterables, objects, strings
13+
from xklb.utils import consts, db_utils, devices, file_utils, iterables, objects, processes, strings
1414
from xklb.utils.consts import DBType
1515
from xklb.utils.log_utils import log
1616

@@ -82,6 +82,7 @@ def parse_args() -> argparse.Namespace:
8282
profile.set_defaults(profile="audio")
8383

8484
parser.add_argument("--only-soft-delete", action="store_true")
85+
parser.add_argument("--dedupe-cmd", help=argparse.SUPPRESS)
8586
parser.add_argument("--force", "-f", action="store_true")
8687
parser.add_argument("--limit", "-L", "-l", "-queue", "--queue", default=100)
8788
parser.add_argument("--include", "-s", "--search", nargs="+", action="extend", default=[], help=argparse.SUPPRESS)
@@ -553,7 +554,12 @@ def dedupe_media() -> None:
553554
for d in duplicates:
554555
path = d["duplicate_path"]
555556
if not path.startswith("http") and not args.only_soft_delete:
556-
file_utils.trash(path, detach=False)
557+
if args.dedupe_cmd:
558+
processes.cmd(
559+
*shlex.split(args.dedupe_cmd), d["duplicate_path"], d["keep_path"]
560+
) # follows rmlint interface
561+
else:
562+
file_utils.trash(path, detach=False)
557563
db_media.mark_media_deleted(args, path)
558564

559565

0 commit comments

Comments
 (0)