тест
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

22
main.py
View File

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