Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix double download of files in http #919

Merged
merged 2 commits into from
Dec 30, 2024
Merged
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
12 changes: 11 additions & 1 deletion lamindb_setup/core/upath.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,17 @@ def download_to(self, local_path: UPathStr, print_progress: bool = True, **kwarg
)
kwargs["callback"] = callback

self.fs.download(str(self), str(local_path), **kwargs)
cloud_path_str = str(self)
local_path_str = str(local_path)

# otherwise fsspec calls fs._ls_real where it reads the body and parses links
# so the file is downloaded 2 times
# upath doesn't call fs.ls to infer type
if self.protocol in {"http", "https"} and self.stat().as_info()["type"] == "file":
self.fs.use_listings_cache = True
self.fs.dircache[cloud_path_str] = []

self.fs.download(cloud_path_str, local_path_str, **kwargs)


def upload_from(
Expand Down
Loading