Initial commit - Migrated to Dev environment
This commit is contained in:
25
backend/app/services/maintenance_service.py
Executable file
25
backend/app/services/maintenance_service.py
Executable file
@@ -0,0 +1,25 @@
|
||||
import os
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
class MaintenanceService:
|
||||
@staticmethod
|
||||
async def cleanup_old_files(storage_path: str):
|
||||
"""1 évnél régebbi fájlok törlése a NAS-ról"""
|
||||
limit = datetime.now() - timedelta(days=365)
|
||||
|
||||
for root, dirs, files in os.walk(storage_path):
|
||||
for file in files:
|
||||
file_path = os.path.join(root, file)
|
||||
file_time = datetime.fromtimestamp(os.path.getmtime(file_path))
|
||||
|
||||
if file_time < limit:
|
||||
os.remove(file_path)
|
||||
print(f"🗑️ Törölve (lejárt): {file}")
|
||||
|
||||
@staticmethod
|
||||
async def delete_validated_evidence(service_id: int, photo_path: str):
|
||||
"""Döntésed: Validáció után a szervizkép törölhető"""
|
||||
if os.path.exists(photo_path):
|
||||
os.remove(photo_path)
|
||||
# Logoljuk az adatbázisba, hogy a kép már nincs meg, de az adat valid
|
||||
Reference in New Issue
Block a user