summaryrefslogtreecommitdiffstats
path: root/modules/storage/storage.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/storage/storage.go')
-rw-r--r--modules/storage/storage.go52
1 files changed, 26 insertions, 26 deletions
diff --git a/modules/storage/storage.go b/modules/storage/storage.go
index a7d3b9ce1f..35f1527172 100644
--- a/modules/storage/storage.go
+++ b/modules/storage/storage.go
@@ -110,46 +110,38 @@ func SaveFrom(objStorage ObjectStorage, p string, callback func(w io.Writer) err
var (
// Attachments represents attachments storage
- Attachments ObjectStorage
+ Attachments ObjectStorage = uninitializedStorage
// LFS represents lfs storage
- LFS ObjectStorage
+ LFS ObjectStorage = uninitializedStorage
// Avatars represents user avatars storage
- Avatars ObjectStorage
+ Avatars ObjectStorage = uninitializedStorage
// RepoAvatars represents repository avatars storage
- RepoAvatars ObjectStorage
+ RepoAvatars ObjectStorage = uninitializedStorage
// RepoArchives represents repository archives storage
- RepoArchives ObjectStorage
+ RepoArchives ObjectStorage = uninitializedStorage
// Packages represents packages storage
- Packages ObjectStorage
+ Packages ObjectStorage = uninitializedStorage
)
// Init init the stoarge
func Init() error {
- if err := initAttachments(); err != nil {
- return err
- }
-
- if err := initAvatars(); err != nil {
- return err
- }
-
- if err := initRepoAvatars(); err != nil {
- return err
- }
-
- if err := initLFS(); err != nil {
- return err
- }
-
- if err := initRepoArchives(); err != nil {
- return err
+ for _, f := range []func() error{
+ initAttachments,
+ initAvatars,
+ initRepoAvatars,
+ initLFS,
+ initRepoArchives,
+ initPackages,
+ } {
+ if err := f(); err != nil {
+ return err
+ }
}
-
- return initPackages()
+ return nil
}
// NewStorage takes a storage type and some config and returns an ObjectStorage or an error
@@ -172,6 +164,10 @@ func initAvatars() (err error) {
}
func initAttachments() (err error) {
+ if !setting.Attachment.Enabled {
+ Attachments = discardStorage("Attachment isn't enabled")
+ return nil
+ }
log.Info("Initialising Attachment storage with type: %s", setting.Attachment.Storage.Type)
Attachments, err = NewStorage(setting.Attachment.Storage.Type, &setting.Attachment.Storage)
return err
@@ -196,6 +192,10 @@ func initRepoArchives() (err error) {
}
func initPackages() (err error) {
+ if !setting.Packages.Enabled {
+ Packages = discardStorage("Packages isn't enabled")
+ return nil
+ }
log.Info("Initialising Packages storage with type: %s", setting.Packages.Storage.Type)
Packages, err = NewStorage(setting.Packages.Storage.Type, &setting.Packages.Storage)
return err