DaniFera commited on
Commit
d4dee55
·
verified ·
1 Parent(s): 7f9b733

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -14,6 +14,7 @@ os.environ["GRADIO_TEMP_DIR"] = config.TEMP_DIR
14
  engine = PDFEngine()
15
 
16
  # --- SEGURIDAD: GARBAGE COLLECTOR CON LOGS VISIBLES ---
 
17
  def cleanup_cron():
18
  """
19
  Revisa cada minuto. Borra archivos Y carpetas mayores a 5 minutos.
@@ -28,15 +29,15 @@ def cleanup_cron():
28
  cutoff = time.time() - (LIMIT_MINUTES * 60)
29
 
30
  # Cabecera de ronda
31
- print(f"--- [SEGURIDAD] Ronda de limpieza: {time.strftime('%H:%M:%S')} ---")
32
 
33
  if os.path.exists(config.TEMP_DIR):
34
  items = os.listdir(config.TEMP_DIR)
35
 
36
  if not items:
37
- print("[ESTADO] Carpeta limpia (0 elementos).")
38
  else:
39
- print(f"[ESTADO] Analizando {len(items)} elementos...")
40
 
41
  for filename in items:
42
  filepath = os.path.join(config.TEMP_DIR, filename)
@@ -64,11 +65,11 @@ def cleanup_cron():
64
  if is_expired:
65
  try:
66
  os.remove(filepath)
67
- print(f"❌ [BORRADO] Archivo {masked} | Edad: {age_str}")
68
  except Exception as e:
69
- print(f"⚠️ [ERROR] No se pudo borrar archivo {masked}: {e}")
70
  else:
71
- print(f"✅ [VIGENTE] Archivo {masked} | Edad: {age_str}")
72
 
73
  # --- CASO 2: ES UNA CARPETA ---
74
  elif os.path.isdir(filepath):
@@ -76,14 +77,14 @@ def cleanup_cron():
76
  try:
77
  # shutil.rmtree borra la carpeta y TODO lo que tenga dentro
78
  shutil.rmtree(filepath)
79
- print(f"🗑️ [LIMPIEZA] Carpeta {masked} eliminada | Edad: {age_str}")
80
  except Exception as e:
81
- print(f"⚠️ [ERROR] No se pudo borrar carpeta {masked}: {e}")
82
  else:
83
- print(f"📂 [VIGENTE] Carpeta {masked} | Edad: {age_str}")
84
 
85
  else:
86
- print("[INFO] Carpeta temporal aún no creada.")
87
 
88
  except Exception as e:
89
  print(f"[CRITICAL] Error en limpieza: {e}")
 
14
  engine = PDFEngine()
15
 
16
  # --- SEGURIDAD: GARBAGE COLLECTOR CON LOGS VISIBLES ---
17
+ # Descomentar los "#print" para ver como funciona el limpiador.
18
  def cleanup_cron():
19
  """
20
  Revisa cada minuto. Borra archivos Y carpetas mayores a 5 minutos.
 
29
  cutoff = time.time() - (LIMIT_MINUTES * 60)
30
 
31
  # Cabecera de ronda
32
+ #print(f"--- [SEGURIDAD] Ronda de limpieza: {time.strftime('%H:%M:%S')} ---")
33
 
34
  if os.path.exists(config.TEMP_DIR):
35
  items = os.listdir(config.TEMP_DIR)
36
 
37
  if not items:
38
+ #print("[ESTADO] Carpeta limpia (0 elementos).")
39
  else:
40
+ #print(f"[ESTADO] Analizando {len(items)} elementos...")
41
 
42
  for filename in items:
43
  filepath = os.path.join(config.TEMP_DIR, filename)
 
65
  if is_expired:
66
  try:
67
  os.remove(filepath)
68
+ #print(f"❌ [BORRADO] Archivo {masked} | Edad: {age_str}")
69
  except Exception as e:
70
+ #print(f"⚠️ [ERROR] No se pudo borrar archivo {masked}: {e}")
71
  else:
72
+ #print(f"✅ [VIGENTE] Archivo {masked} | Edad: {age_str}")
73
 
74
  # --- CASO 2: ES UNA CARPETA ---
75
  elif os.path.isdir(filepath):
 
77
  try:
78
  # shutil.rmtree borra la carpeta y TODO lo que tenga dentro
79
  shutil.rmtree(filepath)
80
+ #print(f"🗑️ [LIMPIEZA] Carpeta {masked} eliminada | Edad: {age_str}")
81
  except Exception as e:
82
+ #print(f"⚠️ [ERROR] No se pudo borrar carpeta {masked}: {e}")
83
  else:
84
+ #print(f"📂 [VIGENTE] Carpeta {masked} | Edad: {age_str}")
85
 
86
  else:
87
+ #print("[INFO] Carpeta temporal aún no creada.")
88
 
89
  except Exception as e:
90
  print(f"[CRITICAL] Error en limpieza: {e}")