From 3d543a88a81604d13f8e401422d59803d9bb3943 Mon Sep 17 00:00:00 2001 From: justindujardin Date: Wed, 15 Apr 2020 17:21:33 -0700 Subject: [PATCH] fix(to_local): issue where files without extensions would not be cached - oops :sweat_smile: --- gcspath/api.py | 2 +- tests/test_api.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcspath/api.py b/gcspath/api.py index c3fa4d3..fdfa9d7 100644 --- a/gcspath/api.py +++ b/gcspath/api.py @@ -166,7 +166,7 @@ def to_local(cls, blob_path: Union["GCSPath", str], recurse: bool = True) -> Pat # If the file isn't in the cache, download it if not cache_blob.exists(): # Is a blob - if cache_blob.suffix != "": + if blob_path.is_file(): dest_folder = cache_blob.parent dest_folder.mkdir(exist_ok=True, parents=True) cache_blob.write_bytes(blob_path.read_bytes()) diff --git a/tests/test_api.py b/tests/test_api.py index 589a91c..0020ced 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -87,7 +87,7 @@ def test_is_path_instance(with_adapter): @pytest.mark.parametrize("adapter", TEST_ADAPTERS) def test_path_to_local(with_adapter): root: GCSPath = GCSPath.from_bucket(bucket) / "to_local" - foo_blob: GCSPath = root / "foo.txt" + foo_blob: GCSPath = root / "foo" foo_blob.write_text("---") assert isinstance(foo_blob, GCSPath) use_fs_cache()