Skip to content

Commit 252dca2

Browse files
committed
Revisión de errores de la nube y solucionado cuelgues de la aplicación
1 parent ea5b2de commit 252dca2

File tree

5 files changed

+281
-73
lines changed

5 files changed

+281
-73
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ jobs:
224224
uses: softprops/action-gh-release@v1
225225
with:
226226
files: |
227-
*.AppImage
227+
VisageVault*.AppImage
228228
*.deb
229229
*.rpm
230230
*.pkg.tar.zst

db_manager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def __init__(self, db_name="visagevault.db", is_worker=False):
2323
self.conn = sqlite3.connect(self.db_path, check_same_thread=False)
2424
self.conn.row_factory = sqlite3.Row # Permite acceder a columnas por nombre
2525

26+
# --- OPTIMIZACIÓN CLAVE: WAL MODE ---
27+
# Permite lecturas y escrituras concurrentes sin bloqueo total
28+
self.conn.execute("PRAGMA journal_mode=WAL;")
29+
self.conn.execute("PRAGMA synchronous=NORMAL;") # Un poco menos seguro ante cortes de luz, pero mucho más rápido
30+
2631
# Solo el hilo principal debe gestionar la estructura de la BD
2732
if not is_worker:
2833
self._create_tables()

drive_manager.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,14 @@ def download_file(self, file_id, local_path):
180180
status, done = downloader.next_chunk()
181181

182182
def list_images_recursively(self, folder_id):
183-
"""Generador recursivo con trazas de depuración."""
183+
"""
184+
Generador recursivo que busca imágenes en todas las subcarpetas.
185+
INCLUYE UN FRENO (time.sleep) para evitar bloquear la interfaz por exceso de velocidad.
186+
"""
184187
if not self.service:
185188
self.authenticate()
186189

187-
# print(f"🔍 Escaneando carpeta ID: {folder_id}...")
188-
189-
# 1. BUSCAR IMÁGENES AQUÍ
190+
# --- PARTE 1: BUSCAR IMÁGENES EN LA CARPETA ACTUAL ---
190191
page_token = None
191192
while True:
192193
query = f"'{folder_id}' in parents and mimeType contains 'image/' and trashed = false"
@@ -203,17 +204,16 @@ def list_images_recursively(self, folder_id):
203204

204205
files = results.get('files', [])
205206
if files:
206-
# print(f" 📸 Encontradas {len(files)} imágenes en esta carpeta.")
207+
# Devuelve este lote de imágenes al Worker para que las guarde
207208
yield files
208209

209210
page_token = results.get('nextPageToken')
210211
if not page_token:
211212
break
212213

213-
# 2. BUSCAR SUBCARPETAS (Para entrar en ellas)
214+
# --- PARTE 2: BUSCAR SUBCARPETAS (RECURSIÓN) ---
214215
page_token = None
215216
while True:
216-
# Buscamos carpetas normales
217217
query = f"'{folder_id}' in parents and mimeType = 'application/vnd.google-apps.folder' and trashed = false"
218218
try:
219219
results = self.service.files().list(
@@ -227,11 +227,19 @@ def list_images_recursively(self, folder_id):
227227
break
228228

229229
subfolders = results.get('files', [])
230+
231+
# === AQUÍ ESTÁ EL FRENO DE EMERGENCIA ===
230232
if subfolders:
231-
print(f" 📂 Encontradas {len(subfolders)} subcarpetas. Entrando...")
233+
# Importamos time aquí por seguridad si no está arriba
234+
import time
235+
236+
# Pequeña pausa (0.1 segundos) antes de procesar las subcarpetas.
237+
# Esto evita que el script entre en 100 carpetas por segundo y sature la CPU.
238+
time.sleep(0.1)
239+
# ========================================
232240

233241
for sub in subfolders:
234-
# Recursión: Entramos en la subcarpeta
242+
# Llamada recursiva: Entramos en la subcarpeta
235243
yield from self.list_images_recursively(sub['id'])
236244

237245
page_token = results.get('nextPageToken')

visagevault.db-shm

32 KB
Binary file not shown.

0 commit comments

Comments
 (0)