Enable cross-search persistent selection, explicit disk deletion confirmations, and 1-click duplicate copy deletion
This commit is contained in:
29
server.py
29
server.py
@@ -523,14 +523,33 @@ def build_dedupe_index():
|
||||
S.dedupe_status = "idle"
|
||||
|
||||
def find_duplicate_groups():
|
||||
"""Groups of exact perceptual-hash matches — visually identical / re-saved copies."""
|
||||
"""Groups of exact perceptual-hash matches and size/filename matches."""
|
||||
records = {r["path"]: r for r in load_search_index()}
|
||||
cache = load_phash_cache()
|
||||
by_hash = {}
|
||||
groups_by_key = {}
|
||||
|
||||
# 1. Group by pHash if available
|
||||
for path, h in cache.items():
|
||||
if path in records:
|
||||
by_hash.setdefault(h, []).append(records[path])
|
||||
groups = [g for g in by_hash.values() if len(g) > 1]
|
||||
if path in records and os.path.exists(path):
|
||||
groups_by_key.setdefault(f"phash:{h}", []).append(records[path])
|
||||
|
||||
# 2. Also group by (file size, filename) for non-hashed or exact size matches
|
||||
by_size_name = {}
|
||||
for path, r in records.items():
|
||||
if path not in cache and os.path.exists(path):
|
||||
try:
|
||||
sz = os.path.getsize(path)
|
||||
name = os.path.basename(path).lower()
|
||||
key = f"size:{sz}_{name}"
|
||||
by_size_name.setdefault(key, []).append(r)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
for key, g in by_size_name.items():
|
||||
if len(g) > 1:
|
||||
groups_by_key[key] = g
|
||||
|
||||
groups = [g for g in groups_by_key.values() if len(g) > 1]
|
||||
groups.sort(key=len, reverse=True)
|
||||
return groups
|
||||
|
||||
|
||||
Reference in New Issue
Block a user