feat: refactor storage configuration to use dedicated storage package and add new storage types

BREAKING CHANGE: remove deprecated config
This commit is contained in:
krau
2025-03-21 20:52:41 +08:00
parent 8e180006f0
commit 65fee89e14
18 changed files with 246 additions and 417 deletions

View File

@@ -12,7 +12,7 @@ import (
"sync"
"time"
"github.com/krau/SaveAny-Bot/config"
config "github.com/krau/SaveAny-Bot/config/storage"
"github.com/krau/SaveAny-Bot/logger"
"github.com/krau/SaveAny-Bot/types"
)

View File

@@ -8,7 +8,7 @@ import (
"net/http"
"time"
"github.com/krau/SaveAny-Bot/config"
config "github.com/krau/SaveAny-Bot/config/storage"
"github.com/krau/SaveAny-Bot/logger"
)

View File

@@ -8,7 +8,7 @@ import (
"path/filepath"
"github.com/duke-git/lancet/v2/fileutil"
"github.com/krau/SaveAny-Bot/config"
config "github.com/krau/SaveAny-Bot/config/storage"
"github.com/krau/SaveAny-Bot/logger"
"github.com/krau/SaveAny-Bot/types"
)

View File

@@ -5,7 +5,7 @@ import (
"fmt"
"path"
"github.com/krau/SaveAny-Bot/config"
config "github.com/krau/SaveAny-Bot/config/storage"
"github.com/krau/SaveAny-Bot/logger"
"github.com/krau/SaveAny-Bot/types"
"github.com/minio/minio-go/v7"

View File

@@ -6,16 +6,17 @@ import (
"io"
"github.com/krau/SaveAny-Bot/config"
sc "github.com/krau/SaveAny-Bot/config/storage"
"github.com/krau/SaveAny-Bot/logger"
"github.com/krau/SaveAny-Bot/storage/alist"
"github.com/krau/SaveAny-Bot/storage/local"
"github.com/krau/SaveAny-Bot/storage/webdav"
"github.com/krau/SaveAny-Bot/storage/minio"
"github.com/krau/SaveAny-Bot/storage/webdav"
"github.com/krau/SaveAny-Bot/types"
)
type Storage interface {
Init(cfg config.StorageConfig) error
Init(cfg sc.StorageConfig) error
Type() types.StorageType
Name() string
JoinStoragePath(task types.Task) string
@@ -94,7 +95,7 @@ var storageConstructors = map[string]StorageConstructor{
string(types.StorageTypeMinio): func() Storage { return new(minio.Minio) },
}
func NewStorage(cfg config.StorageConfig) (Storage, error) {
func NewStorage(cfg sc.StorageConfig) (Storage, error) {
constructor, ok := storageConstructors[string(cfg.GetType())]
if !ok {
return nil, fmt.Errorf("不支持的存储类型: %s", cfg.GetType())

View File

@@ -8,7 +8,7 @@ import (
"path"
"time"
"github.com/krau/SaveAny-Bot/config"
config "github.com/krau/SaveAny-Bot/config/storage"
"github.com/krau/SaveAny-Bot/logger"
"github.com/krau/SaveAny-Bot/types"
)