From 20d65752503355103fac78e5e8d88951c7e1f07e Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Fri, 27 Dec 2019 22:01:34 +0000 Subject: [PATCH 1/2] Ignore empty avatars --- models/migrations/v115.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/models/migrations/v115.go b/models/migrations/v115.go index f1603b797620..6fc0b82512c9 100644 --- a/models/migrations/v115.go +++ b/models/migrations/v115.go @@ -47,7 +47,10 @@ func renameExistingUserAvatarName(x *xorm.Engine) error { for _, user := range users { oldAvatar := user.Avatar - if _, err := os.Stat(filepath.Join(setting.AvatarUploadPath, oldAvatar)); err != nil { + if stat, err := os.Stat(filepath.Join(setting.AvatarUploadPath, oldAvatar)); err != nil || !stat.Mode().IsRegular() { + if stat != nil && stat.IsDir() { + err = fmt.Errorf("Error: \"%s\" is not a regular file", oldAvatar) + } log.Warn("[user: %s] os.Stat: %v", user.LowerName, err) // avatar doesn't exist in the storage // no need to move avatar and update database From 63a74e314e52d727d988de4b581711dd1b852a4f Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Fri, 27 Dec 2019 22:09:24 +0000 Subject: [PATCH 2/2] fixup! Ignore empty avatars --- models/migrations/v115.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/migrations/v115.go b/models/migrations/v115.go index 6fc0b82512c9..67d37536c09e 100644 --- a/models/migrations/v115.go +++ b/models/migrations/v115.go @@ -48,7 +48,7 @@ func renameExistingUserAvatarName(x *xorm.Engine) error { oldAvatar := user.Avatar if stat, err := os.Stat(filepath.Join(setting.AvatarUploadPath, oldAvatar)); err != nil || !stat.Mode().IsRegular() { - if stat != nil && stat.IsDir() { + if err == nil { err = fmt.Errorf("Error: \"%s\" is not a regular file", oldAvatar) } log.Warn("[user: %s] os.Stat: %v", user.LowerName, err)