Browse Source

Allow migrating installations with no local avatars (#1056)

tags/v1.21.12.1
Sandro Santilli Lunny Xiao 8 years ago
parent
commit
bf24099114
2 changed files with 5 additions and 1 deletions
  1. +1
    -1
      models/migrations/migrations.go
  2. +4
    -0
      models/migrations/v20.go

+ 1
- 1
models/migrations/migrations.go View File

@@ -89,7 +89,7 @@ var migrations = []Migration{
// v19 -> v20 // v19 -> v20
NewMigration("generate and migrate Git hooks", generateAndMigrateGitHooks), NewMigration("generate and migrate Git hooks", generateAndMigrateGitHooks),
// v20 -> v21 // 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 // Migrate database to current version


+ 4
- 0
models/migrations/v20.go View File

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


Loading…
Cancel
Save