Allow migrating installations with no local avatars (#1056)

This commit is contained in:
Sandro Santilli 2017-02-26 04:58:02 +01:00 committed by Lunny Xiao
parent 80f900ebae
commit bf24099114
2 changed files with 5 additions and 1 deletions

View file

@ -89,7 +89,7 @@ var migrations = []Migration{
// v19 -> v20
NewMigration("generate and migrate Git hooks", generateAndMigrateGitHooks),
// v20 -> v21
NewMigration("use new avtar path name for security reason", useNewNameAvatars),
NewMigration("use new avatar path name for security reason", useNewNameAvatars),
}
// Migrate database to current version

View file

@ -21,6 +21,10 @@ import (
func useNewNameAvatars(x *xorm.Engine) error {
d, err := os.Open(setting.AvatarUploadPath)
if err != nil {
if os.IsNotExist(err) {
// Nothing to do if AvatarUploadPath does not exist
return nil
}
return err
}
names, err := d.Readdirnames(0)