This commit is contained in:
Ignacio Serantes
2026-04-08 15:47:29 +02:00
parent bff99226b0
commit 07afab6ca3
10 changed files with 336 additions and 113 deletions

View File

@@ -1,3 +1,14 @@
"""
Duplicate Cache and Detection Module for Bagheera.
This module provides the core logic for detecting duplicate images using
perceptual hashing (dHash) and managing a persistent cache of these hashes
and their relationships using LMDB.
Classes:
DuplicateCache: Manages the LMDB database for hashes and exceptions.
DuplicateDetector: Background thread that performs the duplicate analysis.
"""
import os
import logging
import struct
@@ -819,7 +830,8 @@ class DuplicateDetector(QThread):
if time.perf_counter() - last_update_time > 0.05 \
or i == 0 or i == total_queries - 1:
# Scale Comparison to 75% - 100% range
comparison_progress = int(((i + 1) / total_queries) * (total_files / 2)) \
comparison_progress = int(((i + 1) / total_queries)
* (total_files / 2)) \
if total_queries > 0 else (total_files / 2)
self.progress_update.emit(
int(total_files * 1.5 + comparison_progress), total_files * 2,
@@ -856,10 +868,13 @@ class DuplicateDetector(QThread):
# Frequent UI heartbeat for large duplicate groups
if time.perf_counter() - last_update_time > 0.05:
comparison_progress = int(((i + 1) / total_queries) * (total_files / 2))
comparison_progress = int(((i + 1) / total_queries)
* (total_files / 2))
self.progress_update.emit(
int(total_files * 1.5 + comparison_progress), total_files * 2,
UITexts.DUPLICATE_MSG_ANALYZING.format(filename="..."))
int(total_files * 1.5 + comparison_progress),
total_files * 2,
UITexts.DUPLICATE_MSG_ANALYZING.format(
filename="..."))
last_update_time = time.perf_counter()
# Collect for batch update to improve performance