lib/fs: Check both old and new path when renaming (fixes #7426) (#7463)

This commit is contained in:
Simon Frei 2021-03-12 21:15:50 +01:00 committed by GitHub
parent 8a4c00d82e
commit 97a8777d03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -224,6 +224,13 @@ func (f *caseFilesystem) Rename(oldpath, newpath string) error {
if err := f.checkCase(oldpath); err != nil {
return err
}
if err := f.checkCase(newpath); err != nil {
// Case-only rename is ok
e := &ErrCaseConflict{}
if !errors.As(err, &e) || e.Real != oldpath {
return err
}
}
if err := f.Filesystem.Rename(oldpath, newpath); err != nil {
return err
}