Skip to content

Commit d5356d9

Browse files
committed
v1.6, búsqueda de fotos duplicadas
1 parent f1ff4b3 commit d5356d9

File tree

4 files changed

+414
-12
lines changed

4 files changed

+414
-12
lines changed

config_manager.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# config_manager.py
22
import json
3+
import hashlib
34
from pathlib import Path
45

56
CONFIG_FILE = Path("visagevault_config.json")
@@ -53,3 +54,23 @@ def set_drive_folder_id(folder_id):
5354
config = load_config()
5455
config['drive_folder_id'] = folder_id
5556
save_config(config)
57+
58+
def get_safe_password_hash():
59+
"""Obtiene el hash SHA-256 de la contraseña de la caja fuerte."""
60+
config = load_config()
61+
return config.get('safe_password_hash')
62+
63+
def set_safe_password_hash(password):
64+
"""Guarda el hash de la contraseña (NO la contraseña en texto plano)."""
65+
config = load_config()
66+
hash_obj = hashlib.sha256(password.encode('utf-8'))
67+
config['safe_password_hash'] = hash_obj.hexdigest()
68+
save_config(config)
69+
70+
def verify_safe_password(password):
71+
"""Verifica si la contraseña introducida coincide con la guardada."""
72+
stored_hash = get_safe_password_hash()
73+
if not stored_hash: return False
74+
75+
input_hash = hashlib.sha256(password.encode('utf-8')).hexdigest()
76+
return input_hash == stored_hash

db_manager.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ def _create_tables(self):
9494
)
9595
""")
9696

97+
# 6. Tabla de CAJA FUERTE
98+
self.conn.execute("""
99+
CREATE TABLE IF NOT EXISTS safe_files (
100+
id INTEGER PRIMARY KEY AUTOINCREMENT,
101+
original_path TEXT, -- Ruta original para restaurar
102+
encrypted_path TEXT, -- Dónde está ahora (visagevault_safe/...)
103+
media_type TEXT, -- 'photo' o 'video'
104+
original_date TEXT -- Para re-ordenar al restaurar
105+
)
106+
""")
107+
97108
def _check_migrations(self):
98109
"""
99110
Verifica si la base de datos existente necesita actualizaciones de estructura
@@ -438,3 +449,18 @@ def update_drive_photo_date(self, file_id, new_iso_date):
438449
"""
439450
with self.conn:
440451
self.conn.execute("UPDATE drive_photos SET created_time = ? WHERE id = ?", (new_iso_date, file_id))
452+
453+
def add_to_safe(self, original_path, encrypted_path, media_type, date_str):
454+
with self.conn:
455+
self.conn.execute("""
456+
INSERT INTO safe_files (original_path, encrypted_path, media_type, original_date)
457+
VALUES (?, ?, ?, ?)
458+
""", (original_path, encrypted_path, media_type, date_str))
459+
460+
def get_safe_files(self):
461+
cursor = self.conn.execute("SELECT * FROM safe_files")
462+
return cursor.fetchall()
463+
464+
def remove_from_safe(self, encrypted_path):
465+
with self.conn:
466+
self.conn.execute("DELETE FROM safe_files WHERE encrypted_path = ?", (encrypted_path,))

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ numpy
99
opencv-python-headless
1010
rawpy
1111
watchdog
12-
cryptography
12+

0 commit comments

Comments
 (0)