mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-16 01:43:24 +09:00
refactor: retry file remove/rename when a file is busy and clean up os detection (#38588)
Rename functions "util.Remove" (remove.go) to "util.RemoveWithRetry" (file_retry.go) and add comments to clarify their behaviors, also add tests. Refactor callers: when no concurrent access (cmd cli, migration, app init, test), use "os.Xxx" directly. More details are in `modules/util/file_retry.go` By the way, clean up OS (windows) detection, make FileURLToPath test always run
This commit is contained in:
@@ -16,7 +16,6 @@ import (
|
||||
"gitea.dev/modules/container"
|
||||
"gitea.dev/modules/log"
|
||||
"gitea.dev/modules/setting"
|
||||
"gitea.dev/modules/util"
|
||||
)
|
||||
|
||||
func RenameExistingUserAvatarName(x base.EngineMigration) error {
|
||||
@@ -110,8 +109,8 @@ func RenameExistingUserAvatarName(x base.EngineMigration) error {
|
||||
log.Info("Deleting %d old avatars ...", deleteCount)
|
||||
i := 0
|
||||
for file := range deleteList {
|
||||
if err := util.Remove(file); err != nil {
|
||||
log.Warn("util.Remove: %v", err)
|
||||
if err := os.Remove(file); err != nil {
|
||||
log.Warn("Failed to remove avatar %s: %v", file, err)
|
||||
}
|
||||
i++
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user