mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-11 23:59:43 +08:00
feat: (WIP) migrate storage configuration to user-specific models and remove deprecated storage loading
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/krau/SaveAny-Bot/dao"
|
||||
"github.com/krau/SaveAny-Bot/storage/alist"
|
||||
"github.com/krau/SaveAny-Bot/storage/local"
|
||||
"github.com/krau/SaveAny-Bot/storage/webdav"
|
||||
@@ -24,24 +23,6 @@ var (
|
||||
|
||||
var Storages = make(map[uint]Storage)
|
||||
|
||||
// LoadExistingStorages loads existing storages from the database, and initializes them
|
||||
//
|
||||
// Should only be called at startup
|
||||
func LoadExistingStorages() error {
|
||||
storageModels, err := dao.GetActiveStorages()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, storageModel := range storageModels {
|
||||
storage, err := NewStorage(storageModel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
Storages[storageModel.ID] = storage
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get storage from model, if it exists, otherwise create and init a new storage
|
||||
func GetStorageFromModel(model types.StorageModel) (Storage, error) {
|
||||
if model.ID == 0 {
|
||||
|
||||
Reference in New Issue
Block a user