From 45477ab327064017608ca6a58516fe186d339601 Mon Sep 17 00:00:00 2001 From: LawyZheng Date: Fri, 8 Nov 2024 01:09:01 +0800 Subject: [PATCH] fix download file extension (#1157) --- skyvern/forge/agent.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.py index 70bc122d..01497bf2 100644 --- a/skyvern/forge/agent.py +++ b/skyvern/forge/agent.py @@ -5,6 +5,7 @@ import random import string from asyncio.exceptions import CancelledError from datetime import datetime +from pathlib import Path from typing import Any, Tuple import httpx @@ -293,11 +294,12 @@ class ForgeAgent: if len(list_files_after) > len(list_files_before): files_to_rename = list(set(list_files_after) - set(list_files_before)) for file in files_to_rename: + file_extension = Path(file).suffix random_file_id = "".join(random.choices(string.ascii_uppercase + string.digits, k=4)) random_file_name = f"download-{datetime.now().strftime('%Y%m%d%H%M%S%f')}-{random_file_id}" if task_block.download_suffix: random_file_name = f"{random_file_name}-{task_block.download_suffix}" - rename_file(os.path.join(workflow_download_directory, file), random_file_name) + rename_file(os.path.join(workflow_download_directory, file), random_file_name + file_extension) LOG.info( "Task marked as completed due to download",