loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix Storage mapping (#13297)

This PR fixes several bugs in setting storage

* The default STORAGE_TYPE should be the provided type.
* The Storage config should be passed in to NewStorage as a pointer - otherwise the Mappable interface function MapTo will not be found
* There was a bug in the MapTo function.

Fix #13286

Signed-off-by: Andrew Thornton <art27@cantab.net>

authored by

zeripath and committed by
GitHub
172e7ee8 e2740b32

+6 -6
+2 -2
modules/setting/storage.go
··· 21 21 22 22 // MapTo implements the Mappable interface 23 23 func (s *Storage) MapTo(v interface{}) error { 24 - pathValue := reflect.ValueOf(v).FieldByName("Path") 24 + pathValue := reflect.ValueOf(v).Elem().FieldByName("Path") 25 25 if pathValue.IsValid() && pathValue.Kind() == reflect.String { 26 26 pathValue.SetString(s.Path) 27 27 } ··· 46 46 47 47 var storage Storage 48 48 49 - storage.Type = sec.Key("STORAGE_TYPE").MustString("") 49 + storage.Type = sec.Key("STORAGE_TYPE").MustString(typ) 50 50 storage.ServeDirect = sec.Key("SERVE_DIRECT").MustBool(false) 51 51 52 52 // Global Defaults
+4 -4
modules/storage/storage.go
··· 143 143 144 144 func initAvatars() (err error) { 145 145 log.Info("Initialising Avatar storage with type: %s", setting.Avatar.Storage.Type) 146 - Avatars, err = NewStorage(setting.Avatar.Storage.Type, setting.Avatar.Storage) 146 + Avatars, err = NewStorage(setting.Avatar.Storage.Type, &setting.Avatar.Storage) 147 147 return 148 148 } 149 149 150 150 func initAttachments() (err error) { 151 151 log.Info("Initialising Attachment storage with type: %s", setting.Attachment.Storage.Type) 152 - Attachments, err = NewStorage(setting.Attachment.Storage.Type, setting.Attachment.Storage) 152 + Attachments, err = NewStorage(setting.Attachment.Storage.Type, &setting.Attachment.Storage) 153 153 return 154 154 } 155 155 156 156 func initLFS() (err error) { 157 157 log.Info("Initialising LFS storage with type: %s", setting.LFS.Storage.Type) 158 - LFS, err = NewStorage(setting.LFS.Storage.Type, setting.LFS.Storage) 158 + LFS, err = NewStorage(setting.LFS.Storage.Type, &setting.LFS.Storage) 159 159 return 160 160 } 161 161 162 162 func initRepoAvatars() (err error) { 163 163 log.Info("Initialising Repository Avatar storage with type: %s", setting.RepoAvatar.Storage.Type) 164 - RepoAvatars, err = NewStorage(setting.RepoAvatar.Storage.Type, setting.RepoAvatar.Storage) 164 + RepoAvatars, err = NewStorage(setting.RepoAvatar.Storage.Type, &setting.RepoAvatar.Storage) 165 165 return 166 166 }