feat: harden dedupe runtime and NAS deployment
This commit is contained in:
+4
-3
@@ -39,7 +39,7 @@ def choose_winner(rows):
|
||||
return min(rows,key=key)
|
||||
|
||||
|
||||
def exact_dedupe(db_path: Path, root: Path) -> list[tuple[str,str]]:
|
||||
def exact_dedupe(db_path: Path, root: Path, dry_run: bool = False) -> list[tuple[str,str]]:
|
||||
actions=[]
|
||||
with connect(db_path) as conn:
|
||||
rows=conn.execute("SELECT * FROM audio_tracks WHERE status IN ('active','hardlinked')").fetchall()
|
||||
@@ -62,7 +62,8 @@ def exact_dedupe(db_path: Path, root: Path) -> list[tuple[str,str]]:
|
||||
if r["id"]==winner["id"]: continue
|
||||
lp=Path(r["file_path"])
|
||||
if not lp.exists(): continue
|
||||
if lp.stat().st_ino != wp.stat().st_ino: hardlink_duplicate(lp,wp)
|
||||
conn.execute("UPDATE audio_tracks SET status='hardlinked',updated_at=CURRENT_TIMESTAMP WHERE id=?",(r["id"],))
|
||||
if lp.stat().st_ino != wp.stat().st_ino and not dry_run:
|
||||
hardlink_duplicate(lp,wp)
|
||||
conn.execute("UPDATE audio_tracks SET status='hardlinked',updated_at=CURRENT_TIMESTAMP WHERE id=?",(r["id"],))
|
||||
actions.append((str(lp),str(wp)))
|
||||
return actions
|
||||
|
||||
Reference in New Issue
Block a user