Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stale cache info leading to failing isfile check #562

Closed
ianthomas23 opened this issue Jun 23, 2023 · 2 comments · Fixed by #564
Closed

Stale cache info leading to failing isfile check #562

ianthomas23 opened this issue Jun 23, 2023 · 2 comments · Fixed by #564

Comments

@ianthomas23
Copy link
Contributor

Whilst trying to get the new abstract test harness working on gcsfs, I have come across an issue of a gcs.isfile() test erroneously failing.

If you add the following code to gcsfs/tests/test_core.py:

def test_stale_isfile(gcs):
    source = TEST_BUCKET + "/source"
    gcs.mkdir(source)
    gcs.touch(source + "/file2")

    target = TEST_BUCKET + "/target"
    assert not gcs.exists(target)
    gcs.touch(target + "/dummy")
    assert gcs.isdir(target)

    target_file2 = target + "/file2"
    gcs.cp(source + "/file2", target)

    #gcs.find(target, withdirs=True)

    assert gcs.isfile(target_file2)

and run it using pytest -v gcsfs/tests/test_core.py::test_stale_isfile then the isfile assert fails. If you then remove the commented-out line to force a gcs.find then the test passes.

@martindurant
Copy link
Member

find() does possibly do some rewriting of dircache (as in #561 ), so that's what I would look at first. cp() is supposed to reset the dircache for the target, so the other thing to check is whether gcs.invalidate_cache() before isfile gives the correct result.

@ianthomas23
Copy link
Contributor Author

Thanks for the pointers, it turns out that the cp() wasn't invalidating the dircache for the target. Solution is in PR #564.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants