| 1 | //go:build !windows |
| 2 | |
| 3 | package fileutil |
| 4 | |
| 5 | import ( |
| 6 | "errors" |
| 7 | "syscall" |
| 8 | ) |
| 9 | |
| 10 | // renameCrossesDevice reports whether a rename failed with EXDEV: the two |
| 11 | // paths sit on different filesystems, so no retry can make the rename succeed |
| 12 | // and ReplaceFile's copy fallback is the only option. AtomicWriteFile creates |
| 13 | // tmp next to dest, so this only happens when something (an overlay or bind |
| 14 | // mount boundary, or a filter driver on Windows) splits the directory across |
| 15 | // devices. |
| 16 | func renameCrossesDevice(err error) bool { |
| 17 | return errors.Is(err, syscall.EXDEV) |
| 18 | } |
| 19 |