This commit is contained in:
12
main.py
12
main.py
@@ -488,7 +488,7 @@ 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):
|
||||
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))
|
||||
@@ -501,9 +501,9 @@ 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:
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user