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:
zeripathandtechknowlogick authored and GitHub committed 2021-07-15 11:46:07 -04:00
1 parent aed086f8b0
commit 33a8eec33e
8 files changed
+42 -14

No files matched your search

+1 -1
View File
@@ -177,7 +177,7 @@ func (log *FileLogger) DoRotate() error {
// close fd before rename
// Rename the file to its newfound home
if err = os.Rename(log.Filename, fname); err != nil {
if err = util.Rename(log.Filename, fname); err != nil {
return fmt.Errorf("Rotate: %v", err)
}