Closed
Description
Test Script
import contextlib
import os
import fsspec
def cleanup(*files):
for file in files:
with contextlib.suppress(FileNotFoundError):
os.unlink(file)
cleanup("/tmp/test", "/tmp/link")
# Create a file, symlink it to another path and
# delete the original
with open("/tmp/test", "w") as stream:
stream.write("hey")
os.symlink("/tmp/test", "/tmp/link")
os.unlink("/tmp/test")
fs = fsspec.filesystem("file")
print("(fsspec) /tmp/test exists:", fs.exists("/tmp/test"))
print("(fsspec) /tmp/link exists:", fs.exists("/tmp/link"))
print("(os) /tmp/test exists:", os.path.exists("/tmp/test"))
print("(os) /tmp/link exists:", os.path.exists("/tmp/link"))
With the script above, fsspec==2021.07.0
returns True
for fs.exists()
on a symlink where the original file it is linked to is deleted. After 63a668f, it now returns False
since it tries to resolve the links via follow_links=True
.
I personally find the change to make sense, considering this is how the os.path.exists
behaves but I believe it should be explicitly mentioned in the changelog and as well as an option to opt-out from it. Perhaps a keyword option called follow_symlinks=...
to the info
and exists
or a method called lexists()
(similiar to os.path.lexists).
Metadata
Metadata
Assignees
Labels
No labels