Add "keep both" option to dedup review

Lets a candidate be marked ignored instead of confirmed/applied; future
scans skip re-flagging the same path pair once it's been ignored, since
a rescan can flip which side ranks as keep/delete without changing the
user's earlier decision that the pair is fine as two copies. Also adds
--apply-pairs to find-fuzzy-dupes.py to apply pre-confirmed pairs
without a full rescan.
This commit is contained in:
andrew
2026-07-09 08:42:14 -06:00
parent 69804a9eb2
commit 9d1eee3337
6 changed files with 215 additions and 19 deletions
+34 -13
View File
@@ -19,21 +19,25 @@ def _display_path(path: str) -> str:
return path[len(_LIBRARY_PREFIX):] if path.startswith(_LIBRARY_PREFIX) else path
def _to_row(c) -> dict:
return {
"id": c.id,
"pass_name": c.pass_name,
"keep_path": c.keep_path,
"delete_path": c.delete_path,
"keep_display": _display_path(c.keep_path),
"delete_display": _display_path(c.delete_path),
"delete_size_bytes": c.delete_size_bytes,
}
@router.get("")
async def dedup_index(request: Request, user: dict = Depends(require_auth)):
candidates = [
{
"id": c.id,
"pass_name": c.pass_name,
"keep_path": c.keep_path,
"delete_path": c.delete_path,
"keep_display": _display_path(c.keep_path),
"delete_display": _display_path(c.delete_path),
"delete_size_bytes": c.delete_size_bytes,
}
for c in dedup_review_service.list_pending_candidates()
]
return templates.TemplateResponse(request, "dedup/index.html", {"candidates": candidates})
candidates = [_to_row(c) for c in dedup_review_service.list_pending_candidates()]
ignored = [_to_row(c) for c in dedup_review_service.list_ignored_candidates()]
return templates.TemplateResponse(
request, "dedup/index.html", {"candidates": candidates, "ignored": ignored}
)
@router.post("/scan")
@@ -55,3 +59,20 @@ async def confirm(request: Request, user: dict = Depends(require_auth)):
confirmed_by = user.get("email") or user.get("sub", "unknown")
await dedup_review_service.confirm_and_apply(candidate_ids, confirmed_by)
return RedirectResponse(url="/dedup", status_code=303)
@router.post("/ignore")
async def ignore(request: Request, user: dict = Depends(require_auth)):
form = await request.form()
ignored_by = user.get("email") or user.get("sub", "unknown")
for v in form.getlist("candidate_id"):
dedup_review_service.ignore_candidate(int(v), ignored_by)
return RedirectResponse(url="/dedup", status_code=303)
@router.post("/unignore")
async def unignore(request: Request, user: dict = Depends(require_auth)):
form = await request.form()
for v in form.getlist("candidate_id"):
dedup_review_service.unignore_candidate(int(v))
return RedirectResponse(url="/dedup", status_code=303)