diff --git a/fsspec/implementations/cached.py b/fsspec/implementations/cached.py index 5c495e354..89fab0791 100644 --- a/fsspec/implementations/cached.py +++ b/fsspec/implementations/cached.py @@ -355,6 +355,9 @@ def _open( self.save_cache() return f + def _parent(self, path): + return self.fs._parent(path) + def hash_name(self, path: str, *args: Any) -> str: # Kept for backward compatibility with downstream libraries. # Ignores extra arguments, previously same_name boolean. diff --git a/fsspec/implementations/tests/test_cached.py b/fsspec/implementations/tests/test_cached.py index f47be595a..524e537fe 100644 --- a/fsspec/implementations/tests/test_cached.py +++ b/fsspec/implementations/tests/test_cached.py @@ -1271,3 +1271,4 @@ def test_spurious_directory_issue1410(tmpdir): # There was a bug reported in issue #1410 in which a directory # would be created and the next assertion would fail. assert len(os.listdir()) == 1 + assert fs._parent("/any/path") == "any" # correct for ZIP, which has no leading / diff --git a/fsspec/spec.py b/fsspec/spec.py index c745fdaa3..dffbeb895 100644 --- a/fsspec/spec.py +++ b/fsspec/spec.py @@ -887,7 +887,8 @@ def get_file( os.makedirs(lpath, exist_ok=True) return None - LocalFileSystem(auto_mkdir=True).makedirs(self._parent(lpath), exist_ok=True) + fs = LocalFileSystem(auto_mkdir=True) + fs.makedirs(fs._parent(lpath), exist_ok=True) with self.open(rpath, "rb", **kwargs) as f1: if outfile is None: