Open
Description
As discussed in #542 a file is deleted in some cases when moved onto itself. Working example:
from fs import open_fs
with open_fs("mem://") as currdir:
currdir.writetext("test.txt", "Content")
currdir.move("test.txt", "test.txt", overwrite=True)
assert currdir.exists("test.txt")
# -> raises AssertionError
This happens in both fs.base.FS.move
and fs.move.move_file
.
Due to the optimization in #523 this does not happen on OSFS, but applies to other filesystems with shared connections. For example when moving a file from one connection to a ftp server onto itself in another connection to the same ftp server.
For a solution a function is needed to check whether two different (fs, path)
tuples point to the same resource.