Skip to content

Commit

Permalink
Test bug reported in #1410
Browse files Browse the repository at this point in the history
Spurious directory created using cache.
  • Loading branch information
horta committed Nov 6, 2023
1 parent 811d5d8 commit 050236f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion fsspec/implementations/tests/test_cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
HashCacheMapper,
create_cache_mapper,
)
from fsspec.implementations.cached import CachingFileSystem, LocalTempFile
from fsspec.implementations.cached import (
CachingFileSystem,
LocalTempFile,
WholeFileCacheFileSystem,
)
from fsspec.implementations.local import make_path_posix
from fsspec.implementations.zip import ZipFileSystem
from fsspec.tests.conftest import win

from .test_ftp import FTPFileSystem
Expand Down Expand Up @@ -1250,3 +1255,19 @@ def test_cache_size(tmpdir, protocol):
else:
# Whole cache directory has been deleted
assert fs.cache_size() == 0


def test_spurious_directory_issue1410(tmpdir):
import zipfile

os.chdir(tmpdir)
zipfile.ZipFile("dir.zip", mode="w").open("file.txt", "w").write(b"hello")
fs = WholeFileCacheFileSystem(fs=ZipFileSystem("dir.zip"))

assert len(os.listdir()) == 1
with fs.open("/file.txt", "rb"):
pass

# 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

0 comments on commit 050236f

Please sign in to comment.