feat: make NAS self-build deployment canonical

This commit is contained in:
OpenClaw Agent
2026-09-18 05:13:22 +08:00
parent 7219d93b99
commit e08010610e
6 changed files with 186 additions and 88 deletions
+17 -10
View File
@@ -9,25 +9,32 @@ from .scanner import scan
from .watcher import watch
def _db_path(root: Path, explicit: Path | None) -> Path:
if explicit:
return explicit
if str(root).startswith("/music/"):
return Path("/data/dedupe.db")
return root / ".dedupe" / "dedupe.db"
def main() -> None:
parser = argparse.ArgumentParser(prog="am-deduper")
sub = parser.add_subparsers(dest="cmd", required=True)
def add_common(sp):
for name in ("scan", "dedupe", "reconcile"):
sp = sub.add_parser(name)
sp.add_argument("root", type=Path)
sp.add_argument("--db", type=Path, default=None)
sp.add_argument("--dry-run", action="store_true", help="report actions without changing files")
if name != "scan":
sp.add_argument("--dry-run", action="store_true")
add_common(sub.add_parser("scan"))
add_common(sub.add_parser("dedupe"))
add_common(sub.add_parser("reconcile"))
watch_parser = sub.add_parser("watch")
watch_parser.add_argument("root", type=Path)
watch_parser.add_argument("--db", type=Path, default=None)
watch_parser.add_argument("--l2", action="store_true", help="enable acoustic matching in the watcher")
wp = sub.add_parser("watch")
wp.add_argument("root", type=Path)
wp.add_argument("--db", type=Path, default=None)
wp.add_argument("--l2", action="store_true", help="enable acoustic matching")
args = parser.parse_args()
db = args.db or (Path("/data/dedupe.db") if args.cmd != "watch" and str(args.root).startswith("/music/") else args.root / ".dedupe" / "dedupe.db")
db = _db_path(args.root, args.db)
if args.cmd == "watch":
watch(args.root, db, l2=args.l2)