Adauga stergere automata fisiere inainte de scraping
La comenzile /scrape* se sterg automat fisierele CSV, JSON, ZIP si PNG anterioare pentru a preveni acumularea de date vechi. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -125,6 +125,44 @@ class TelegramTriggerBot:
|
||||
logging.warning("Nu am putut salva message_id pentru progress updates")
|
||||
|
||||
try:
|
||||
# Șterge fișierele CSV, ZIP și PNG anterioare
|
||||
data_dir = Path('data')
|
||||
if data_dir.exists():
|
||||
deleted_count = 0
|
||||
|
||||
# Șterge CSV-uri de solduri
|
||||
for f in data_dir.glob('solduri_*.csv'):
|
||||
f.unlink()
|
||||
deleted_count += 1
|
||||
logging.info(f"Șters: {f.name}")
|
||||
|
||||
# Șterge CSV-uri de tranzacții
|
||||
for f in data_dir.glob('tranzactii_*.csv'):
|
||||
f.unlink()
|
||||
deleted_count += 1
|
||||
logging.info(f"Șters: {f.name}")
|
||||
|
||||
# Șterge JSON-uri
|
||||
for f in data_dir.glob('solduri_*.json'):
|
||||
f.unlink()
|
||||
deleted_count += 1
|
||||
logging.info(f"Șters: {f.name}")
|
||||
|
||||
# Șterge ZIP-uri
|
||||
for f in data_dir.glob('btgo_export_*.zip'):
|
||||
f.unlink()
|
||||
deleted_count += 1
|
||||
logging.info(f"Șters: {f.name}")
|
||||
|
||||
# Șterge PNG-uri (screenshot-uri Playwright)
|
||||
for f in data_dir.glob('*.png'):
|
||||
f.unlink()
|
||||
deleted_count += 1
|
||||
logging.info(f"Șters: {f.name}")
|
||||
|
||||
if deleted_count > 0:
|
||||
logging.info(f"Total {deleted_count} fisiere sterse inainte de scraping")
|
||||
|
||||
# Rulează scraper-ul
|
||||
logging.info(f"Pornire scraper (send_as_zip={send_as_zip}, balances_only={balances_only})...")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user