Skip to content

Commit 2b87bff

Browse files
authored
fix: always convert blocks from list to set when loading cache metadata (#1556)
1 parent 47b445a commit 2b87bff

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

fsspec/implementations/cache_metadata.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ def _load(self, fn: str) -> Detail:
5757
"""Low-level function to load metadata from specific file"""
5858
try:
5959
with open(fn, "r") as f:
60-
return json.load(f)
60+
loaded = json.load(f)
6161
except ValueError:
6262
with open(fn, "rb") as f:
63-
return pickle.load(f)
63+
loaded = pickle.load(f)
64+
for c in loaded.values():
65+
if isinstance(c.get("blocks"), list):
66+
c["blocks"] = set(c["blocks"])
67+
return loaded
6468

6569
def _save(self, metadata_to_save: Detail, fn: str) -> None:
6670
"""Low-level function to save metadata to specific file"""
@@ -152,11 +156,7 @@ def load(self) -> None:
152156
for fn, _, _ in self._scan_locations():
153157
if os.path.exists(fn):
154158
# TODO: consolidate blocks here
155-
loaded_cached_files = self._load(fn)
156-
for c in loaded_cached_files.values():
157-
if isinstance(c["blocks"], list):
158-
c["blocks"] = set(c["blocks"])
159-
cached_files.append(loaded_cached_files)
159+
cached_files.append(self._load(fn))
160160
else:
161161
cached_files.append({})
162162
self.cached_files = cached_files or [{}]

0 commit comments

Comments
 (0)