тест
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-04-07 09:42:09 +10:00
parent 5eec71b4a1
commit c007a119ab

18
main.py
View File

@@ -488,10 +488,10 @@ async def download_all(dates: DownloadRange):
full_dir_path = os.path.join(DOCUMENTS_DIR, date_path) full_dir_path = os.path.join(DOCUMENTS_DIR, date_path)
logger.info(f"Проверяем путь: {full_dir_path}") logger.info(f"Проверяем путь: {full_dir_path}")
# if os.path.exists(full_dir_path): if os.path.exists(full_dir_path):
for file in os.listdir(full_dir_path): for file in os.listdir(full_dir_path):
if file.endswith('.docx'): if file.endswith('.docx'):
all_files.append(os.path.join(full_dir_path, file)) all_files.append(os.path.join(full_dir_path, file))
current_date += timedelta(days=1) current_date += timedelta(days=1)
@@ -501,9 +501,9 @@ async def download_all(dates: DownloadRange):
if not all_files: if not all_files:
return {"error": "Файлы не найдены за указанный период", "date_start": date_start, "date_finish": date_finish} return {"error": "Файлы не найдены за указанный период", "date_start": date_start, "date_finish": date_finish}
# Создаём архив во временной директории # Создаём архив в директории DOCUMENTS_DIR
archive_name = f"documents.zip" archive_name = f"documents_{date_start}_{date_finish}.zip"
archive_path = os.path.join(tempfile.gettempdir(), archive_name) archive_path = os.path.join(DOCUMENTS_DIR, archive_name)
try: try:
with zipfile.ZipFile(archive_path, 'w', zipfile.ZIP_DEFLATED) as zipf: with zipfile.ZipFile(archive_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
@@ -545,5 +545,5 @@ def get_logs():
lines = file.readlines()[-10:] # последние 10 строк lines = file.readlines()[-10:] # последние 10 строк
return {"logs": lines} return {"logs": lines}
# if __name__ == "__main__": if __name__ == "__main__":
# uvicorn.run("main:app", port=8001, reload=True) uvicorn.run("main:app", port=8001, reload=True)