Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion application_sdk/services/objectstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import os
import shutil
from pathlib import Path
from typing import List, Union

import orjson
Expand Down Expand Up @@ -422,14 +423,18 @@ async def download_prefix(
store_name: Name of the Dapr object store binding to use.
"""
try:
# Convert destination to Path object for cross-platform compatibility
dest_path = Path(destination)

# List all files under the prefix
file_list = await cls.list_files(source, store_name)

logger.info(f"Found {len(file_list)} files to download from: {source}")

# Download each file
for file_path in file_list:
local_file_path = os.path.join(destination, file_path)
# Use Path for proper OS-independent path joining
local_file_path = str(dest_path / file_path)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Pathlib normalization breaks current directory file downloads

The migration from os.path.join to pathlib.Path introduces a behavioral regression. When destination is "." (current directory) and file_path is a filename-only string (returned by list_files when prefix isn't found in path), Path(".") / "file.txt" normalizes to just "file.txt" whereas os.path.join(".", "file.txt") preserved the "./" prefix. This causes download_file to call os.makedirs("") which raises FileNotFoundError, since os.path.dirname("file.txt") returns an empty string instead of ".".

Fix in Cursor Fix in Web

await cls.download_file(file_path, local_file_path, store_name)

logger.info(f"Successfully downloaded all files from: {source}")
Expand Down
Loading