Skip to content

Commit cbad40c

Browse files
authored
Don't let find() mess up dircache (#531)
1 parent 3d7c9a9 commit cbad40c

File tree

5 files changed

+40
-16
lines changed

5 files changed

+40
-16
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ jobs:
4949
name: lint
5050
runs-on: ubuntu-latest
5151
steps:
52-
- uses: actions/checkout@v3.1.0
52+
- uses: actions/checkout@v3
5353
- uses: actions/setup-python@v4
54-
with:
55-
python-version: "3.9"
56-
- uses: pre-commit/[email protected]
54+
- uses: pre-commit/[email protected]

.isort.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[settings]
2+
known_third_party = aiohttp,click,decorator,fsspec,fuse,google,google_auth_oauthlib,pytest,requests,setuptools

.pre-commit-config.yaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@ repos:
1818
rev: 6.0.0
1919
hooks:
2020
- id: flake8
21-
files: gcsfs/
22-
- repo: https://github.com/pycqa/isort
23-
rev: 5.10.1
21+
- repo: https://github.com/asottile/seed-isort-config
22+
rev: v2.2.0
2423
hooks:
25-
- id: isort
26-
args: ["--profile", "black", "--filter-files"]
27-
- repo: https://github.com/asottile/pyupgrade
28-
rev: v3.2.3
24+
- id: seed-isort-config
25+
- repo: https://github.com/pre-commit/mirrors-isort
26+
rev: v5.7.0
2927
hooks:
30-
- id: pyupgrade
31-
args:
32-
- --py37-plus
28+
- id: isort

gcsfs/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,10 @@ async def _find(
12201220
"size": 0,
12211221
}
12221222

1223-
cache_entries.setdefault(parent, []).append(previous)
1223+
print(parent, previous)
1224+
listing = cache_entries.setdefault(parent, [])
1225+
if previous not in listing:
1226+
listing.append(previous)
12241227

12251228
previous = dirs[parent]
12261229
parent = self._parent(parent)

gcsfs/tests/test_core.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@
1414
from fsspec.utils import seek_delimiter
1515

1616
import gcsfs.checkers
17+
import gcsfs.tests.settings
1718
from gcsfs import __version__ as version
1819
from gcsfs.core import GCSFileSystem, quote
1920
from gcsfs.credentials import GoogleCredentials
2021
from gcsfs.tests.conftest import a, allfiles, b, csv_files, files, text_files
21-
from gcsfs.tests.settings import TEST_BUCKET, TEST_PROJECT, TEST_REQUESTER_PAYS_BUCKET
2222
from gcsfs.tests.utils import tempdir, tmpfile
2323

24+
TEST_BUCKET = gcsfs.tests.settings.TEST_BUCKET
25+
TEST_PROJECT = gcsfs.tests.settings.TEST_PROJECT
26+
TEST_REQUESTER_PAYS_BUCKET = gcsfs.tests.settings.TEST_REQUESTER_PAYS_BUCKET
27+
2428

2529
def test_simple(gcs):
2630
assert not GoogleCredentials.tokens
@@ -1339,3 +1343,24 @@ def test_cp_two_files(gcs):
13391343
target + "/file0",
13401344
target + "/file1",
13411345
]
1346+
1347+
1348+
def test_multiglob(gcs):
1349+
# #530
1350+
root = TEST_BUCKET
1351+
1352+
ggparent = root + "/t1"
1353+
gparent = ggparent + "/t2"
1354+
parent = gparent + "/t3"
1355+
leaf1 = parent + "/foo.txt"
1356+
leaf2 = parent + "/bar.txt"
1357+
leaf3 = parent + "/baz.txt"
1358+
1359+
gcs.touch(leaf1)
1360+
gcs.touch(leaf2)
1361+
gcs.touch(leaf3)
1362+
gcs.invalidate_cache()
1363+
1364+
assert gcs.ls(gparent, detail=False) == [f"{root}/t1/t2/t3"]
1365+
gcs.glob(ggparent + "/")
1366+
assert gcs.ls(gparent, detail=False) == [f"{root}/t1/t2/t3"]

0 commit comments

Comments
 (0)