* Fix Storage mapping (#13297) Backport #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> * add missing changes from backport #13164 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
d795bfc964
commit
5da8a84328
4 changed files with 29 additions and 17 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -141,21 +142,25 @@ func NewStorage(typStr string, cfg interface{}) (ObjectStorage, error) {
|
|||
}
|
||||
|
||||
func initAvatars() (err error) {
|
||||
Avatars, err = NewStorage(setting.Avatar.Storage.Type, setting.Avatar.Storage)
|
||||
log.Info("Initialising Avatar storage with type: %s", setting.Avatar.Storage.Type)
|
||||
Avatars, err = NewStorage(setting.Avatar.Storage.Type, &setting.Avatar.Storage)
|
||||
return
|
||||
}
|
||||
|
||||
func initAttachments() (err error) {
|
||||
Attachments, err = NewStorage(setting.Attachment.Storage.Type, setting.Attachment.Storage)
|
||||
log.Info("Initialising Attachment storage with type: %s", setting.Attachment.Storage.Type)
|
||||
Attachments, err = NewStorage(setting.Attachment.Storage.Type, &setting.Attachment.Storage)
|
||||
return
|
||||
}
|
||||
|
||||
func initLFS() (err error) {
|
||||
LFS, err = NewStorage(setting.LFS.Storage.Type, setting.LFS.Storage)
|
||||
log.Info("Initialising LFS storage with type: %s", setting.LFS.Storage.Type)
|
||||
LFS, err = NewStorage(setting.LFS.Storage.Type, &setting.LFS.Storage)
|
||||
return
|
||||
}
|
||||
|
||||
func initRepoAvatars() (err error) {
|
||||
RepoAvatars, err = NewStorage(setting.RepoAvatar.Storage.Type, setting.RepoAvatar.Storage)
|
||||
log.Info("Initialising Repository Avatar storage with type: %s", setting.RepoAvatar.Storage.Type)
|
||||
RepoAvatars, err = NewStorage(setting.RepoAvatar.Storage.Type, &setting.RepoAvatar.Storage)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue