Skip to content
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: 12 additions & 0 deletions fsspec/implementations/cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ def _open(
self._metadata.update_file(path, detail)
logger.debug("Creating local sparse file for %s", path)

# explicitly submitting the size to the open call will avoid extra
# operations when opening. This is particularly relevant
# for any file that is read over a network, e.g. S3.
size = detail.get("size", None)

# call target filesystems open
self._mkcache()
f = self.fs._open(
Expand All @@ -344,8 +349,15 @@ def _open(
autocommit=autocommit,
cache_options=cache_options,
cache_type="none",
size=size,
**kwargs,
)

# set size if not already set
if size is None:
detail["size"] = f.size
self._metadata.update_file(path, detail)

if self.compression:
comp = (
infer_compression(path)
Expand Down
Loading