feat: (WIP) migrate storage configuration to user-specific models and remove deprecated storage loading

This commit is contained in:
krau
2025-02-18 19:45:06 +08:00
parent 968547b005
commit dfde65c28e
8 changed files with 193 additions and 36 deletions

View File

@@ -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 {