Skip to content

Commit 89d86ae

Browse files
committed
Conexión google arreglada
1 parent e7c7c15 commit 89d86ae

File tree

2 files changed

+24
-34
lines changed

2 files changed

+24
-34
lines changed

db_manager.py

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,39 @@
1010
from pathlib import Path
1111

1212
class VisageVaultDB:
13-
# Modificar __init__ para aceptar 'db_path'
1413
def __init__(self, db_path=None, is_worker=False):
14+
# --- 1. INICIALIZACIÓN SEGURA (Variables por defecto) ---
15+
# Definimos esto PRIMERO para que existan aunque todo lo demás falle.
16+
self.conn = None
17+
self.meta_conn = None
18+
self.was_reset = False # <--- Esto arregla el AttributeError
19+
self.is_worker = is_worker
1520

16-
# 1. Gestión de la ruta de la BD
21+
# --- 2. CONFIGURACIÓN DE RUTA ---
1722
if db_path:
18-
# Si nos pasan una ruta (desde AUR/Linux), la usamos
1923
self.db_path = db_path
2024
else:
21-
# Si no (Windows/Dev), usamos la local junto al script
25+
# Modo Dev/Windows
2226
base_dir = os.path.dirname(os.path.abspath(__file__))
2327
self.db_path = os.path.join(base_dir, "visagevault.db")
2428

25-
# Asegurar que el directorio existe (por seguridad)
26-
os.makedirs(os.path.dirname(self.db_path), exist_ok=True)
27-
28-
self.is_worker = is_worker
29-
self.conn = None
30-
31-
# 2. Intentar conectar a la BD Principal
29+
# --- 3. CREACIÓN DE DIRECTORIOS ---
3230
try:
33-
self._connect_main_db()
34-
35-
if not is_worker:
36-
# CHEQUEO DE SALUD
37-
if not self._check_integrity():
38-
raise sqlite3.DatabaseError("La base de datos está corrupta o es incompatible.")
39-
40-
# Si llegamos aquí, la BD está sana.
41-
# Hacemos backup de los datos actuales a la MetaDB por seguridad
42-
self._sync_main_to_meta()
43-
44-
self._create_tables()
45-
self._check_migrations()
46-
47-
except (sqlite3.DatabaseError, sqlite3.OperationalError) as e:
48-
if is_worker:
49-
# Un worker no debe intentar arreglar la BD, solo fallar
50-
print(f"Worker falló al conectar DB: {e}")
51-
raise e
31+
# Aseguramos que la carpeta donde va la DB existe (vital para ~/.local/share/...)
32+
db_dir = os.path.dirname(self.db_path)
33+
if db_dir and not os.path.exists(db_dir):
34+
os.makedirs(db_dir, exist_ok=True)
35+
except Exception as e:
36+
print(f"Error crítico creando directorio de DB: {e}")
5237

53-
print(f"❌ ERROR CRÍTICO EN BD: {e}")
54-
print("🔄 Iniciando protocolo de AUTOREPARACIÓN...")
55-
self._perform_hard_reset()
38+
# --- 4. CONEXIÓN ---
39+
# Solo conectamos si todo lo anterior fue bien
40+
if not self.is_worker:
41+
try:
42+
self._connect_main_db()
43+
self._init_db()
44+
except Exception as e:
45+
print(f"Error inicializando DB: {e}")
5646

5747
def _connect_main_db(self):
5848
"""Conexión estándar con optimizaciones."""

visagevault.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ==============================================================================
22
# PROYECTO: VisageVault - Gestor de Fotografías Inteligente
3-
# VERSIÓN: 1.6.10
3+
# VERSIÓN: 1.6.11
44
# DERECHOS DE AUTOR: © 2025 Daniel Serrano Armenta
55
# ==============================================================================
66
#

0 commit comments

Comments
 (0)