Skip to content

Commit

Permalink
fix download file extension (#1157)
Browse files Browse the repository at this point in the history
  • Loading branch information
LawyZheng authored Nov 7, 2024
1 parent 2252148 commit 45477ab
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion skyvern/forge/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import string
from asyncio.exceptions import CancelledError
from datetime import datetime
from pathlib import Path
from typing import Any, Tuple

import httpx
Expand Down Expand Up @@ -293,11 +294,12 @@ async def execute_step(
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",
Expand Down

0 comments on commit 45477ab

Please sign in to comment.