Skip to content

Commit 20d6575

Browse files
committed
Ignore empty avatars
1 parent 4acca9d commit 20d6575

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

models/migrations/v115.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ func renameExistingUserAvatarName(x *xorm.Engine) error {
4747
for _, user := range users {
4848
oldAvatar := user.Avatar
4949

50-
if _, err := os.Stat(filepath.Join(setting.AvatarUploadPath, oldAvatar)); err != nil {
50+
if stat, err := os.Stat(filepath.Join(setting.AvatarUploadPath, oldAvatar)); err != nil || !stat.Mode().IsRegular() {
51+
if stat != nil && stat.IsDir() {
52+
err = fmt.Errorf("Error: \"%s\" is not a regular file", oldAvatar)
53+
}
5154
log.Warn("[user: %s] os.Stat: %v", user.LowerName, err)
5255
// avatar doesn't exist in the storage
5356
// no need to move avatar and update database

0 commit comments

Comments
 (0)