alist/internal/bootstrap/storage.go

31 lines
830 B
Go
Raw Normal View History

2022-08-11 13:32:33 +00:00
package bootstrap
import (
"context"
"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/db"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/op"
2022-08-30 07:22:54 +00:00
"github.com/alist-org/alist/v3/pkg/utils"
2022-08-11 13:32:33 +00:00
)
func LoadStorages() {
storages, err := db.GetEnabledStorages()
if err != nil {
2022-08-30 07:22:54 +00:00
utils.Log.Fatalf("failed get enabled storages: %+v", err)
2022-08-11 13:32:33 +00:00
}
go func(storages []model.Storage) {
for i := range storages {
err := op.LoadStorage(context.Background(), storages[i])
2022-08-11 13:32:33 +00:00
if err != nil {
2022-08-30 07:22:54 +00:00
utils.Log.Errorf("failed get enabled storages: %+v", err)
2022-08-11 13:32:33 +00:00
} else {
2024-04-19 09:22:16 +00:00
utils.Log.Infof("success load storage: [%s], driver: [%s], order: [%d]",
storages[i].MountPath, storages[i].Driver, storages[i].Order)
2022-08-11 13:32:33 +00:00
}
}
conf.StoragesLoaded = true
}(storages)
}