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>
This commit is contained in:
zeripath 2021-07-15 16:46:07 +01:00 committed by GitHub
parent aed086f8b0
commit 33a8eec33e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 14 deletions

View file

@ -842,7 +842,7 @@ func rewriteAllPublicKeys(e Engine) error {
}
t.Close()
return os.Rename(tmpPath, fPath)
return util.Rename(tmpPath, fPath)
}
// RegeneratePublicKeys regenerates the authorized_keys file
@ -1324,7 +1324,7 @@ func rewriteAllPrincipalKeys(e Engine) error {
}
t.Close()
return os.Rename(tmpPath, fPath)
return util.Rename(tmpPath, fPath)
}
// ListPrincipalKeys returns a list of principals belongs to given user.