os: SameFile should not only check inodes and devices #36895
Labels
FrozenDueToAge
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
What version of Go are you using (
go version
)?tip
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Every Unix systems (tested on AIX and Linux).
What did you do?
I'm calling os.SameFile to check if a file have been moved, using the two FileInfos associated with the old path and the new path.
However, there is some case where the device and the inode are the same.
I don't have a pure Go example, as it isn't 100% reproducible. But, here is a bash version.
As you can see, both files end up with the same inode. Therefore, os.SameFile on Unix systems will return true, even if it's one is a basic file and one a directory.
I think it's acceptable when two basic files are involved (it can be considered as a "move" and a "write" afterall), same for two directories. But for the shown case, it seems weird to me. I don't know if there is a way to transform a file to a directory directly.
Shouldn't os.SameFile also check IsDir() ?
The text was updated successfully, but these errors were encountered: