Retry rename on lock induced failures (#16435) (#16439)

Backport #16435

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>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
zeripathandtechknowlogick authored and GitHub committed 2021-07-15 22:57:51 +03:00
1 parent 58615be523
commit ca55e49cc0
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)
}