mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-12 02:09:43 +08:00
feat: refactor storage configuration to use dedicated storage package and add new storage types
BREAKING CHANGE: remove deprecated config
This commit is contained in:
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user