diff options
author | zeripath <art27@cantab.net> | 2021-07-15 16:46:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-15 11:46:07 -0400 |
commit | 33a8eec33e975a74f1718a83e99eb6abc7662a19 (patch) | |
tree | d000ff3f37d417e9d03d15d070ed6fecf9c56636 /models/user.go | |
parent | aed086f8b021f5724ff1449ceb9f44dc28749a97 (diff) | |
download | gitea-33a8eec33e975a74f1718a83e99eb6abc7662a19.tar.gz gitea-33a8eec33e975a74f1718a83e99eb6abc7662a19.zip |
Retry rename on lock induced failures (#16435)
* Retry rename on lock induced failures
Due to external locking on Windows it is possible for an
os.Rename to fail if the files or directories are being
used elsewhere.
This PR simply suggests retrying the rename again similar
to how we handle the os.Remove problems.
Fix #16427
Signed-off-by: Andrew Thornton <art27@cantab.net>
* resolve CI fail
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/models/user.go b/models/user.go index 3b8ce79251..f606da53d6 100644 --- a/models/user.go +++ b/models/user.go @@ -1027,7 +1027,7 @@ func ChangeUserName(u *User, newUserName string) (err error) { } // Do not fail if directory does not exist - if err = os.Rename(UserPath(oldUserName), UserPath(newUserName)); err != nil && !os.IsNotExist(err) { + if err = util.Rename(UserPath(oldUserName), UserPath(newUserName)); err != nil && !os.IsNotExist(err) { return fmt.Errorf("Rename user directory: %v", err) } @@ -1036,7 +1036,7 @@ func ChangeUserName(u *User, newUserName string) (err error) { } if err = sess.Commit(); err != nil { - if err2 := os.Rename(UserPath(newUserName), UserPath(oldUserName)); err2 != nil && !os.IsNotExist(err2) { + if err2 := util.Rename(UserPath(newUserName), UserPath(oldUserName)); err2 != nil && !os.IsNotExist(err2) { log.Critical("Unable to rollback directory change during failed username change from: %s to: %s. DB Error: %v. Filesystem Error: %v", oldUserName, newUserName, err, err2) return fmt.Errorf("failed to rollback directory change during failed username change from: %s to: %s. DB Error: %w. Filesystem Error: %v", oldUserName, newUserName, err, err2) } |