chore: rename VirtualPath
to MountPath
This commit is contained in:
parent
fbc858b43c
commit
2bff656f00
@ -45,7 +45,7 @@ func AddURI(ctx context.Context, uri string, dstDirPath string) error {
|
|||||||
}
|
}
|
||||||
DownTaskManager.Submit(task.WithCancelCtx(&task.Task[string]{
|
DownTaskManager.Submit(task.WithCancelCtx(&task.Task[string]{
|
||||||
ID: gid,
|
ID: gid,
|
||||||
Name: fmt.Sprintf("download %s to [%s](%s)", uri, storage.GetStorage().VirtualPath, dstDirActualPath),
|
Name: fmt.Sprintf("download %s to [%s](%s)", uri, storage.GetStorage().MountPath, dstDirActualPath),
|
||||||
Func: func(tsk *task.Task[string]) error {
|
Func: func(tsk *task.Task[string]) error {
|
||||||
m := &Monitor{
|
m := &Monitor{
|
||||||
tsk: tsk,
|
tsk: tsk,
|
||||||
|
@ -39,13 +39,13 @@ func TestConnect(t *testing.T) {
|
|||||||
func TestDown(t *testing.T) {
|
func TestDown(t *testing.T) {
|
||||||
TestConnect(t)
|
TestConnect(t)
|
||||||
err := operations.CreateStorage(context.Background(), model.Storage{
|
err := operations.CreateStorage(context.Background(), model.Storage{
|
||||||
ID: 0,
|
ID: 0,
|
||||||
VirtualPath: "/",
|
MountPath: "/",
|
||||||
Index: 0,
|
Index: 0,
|
||||||
Driver: "Local",
|
Driver: "Local",
|
||||||
Status: "",
|
Status: "",
|
||||||
Addition: `{"root_folder":"../../data"}`,
|
Addition: `{"root_folder":"../../data"}`,
|
||||||
Remark: "",
|
Remark: "",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create storage: %+v", err)
|
t.Fatalf("failed to create storage: %+v", err)
|
||||||
|
@ -135,7 +135,7 @@ func (m *Monitor) Complete() error {
|
|||||||
}()
|
}()
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
TransferTaskManager.Submit(task.WithCancelCtx[uint64](&task.Task[uint64]{
|
TransferTaskManager.Submit(task.WithCancelCtx[uint64](&task.Task[uint64]{
|
||||||
Name: fmt.Sprintf("transfer %s to [%s](%s)", file.Path, storage.GetStorage().VirtualPath, dstDirActualPath),
|
Name: fmt.Sprintf("transfer %s to [%s](%s)", file.Path, storage.GetStorage().MountPath, dstDirActualPath),
|
||||||
Func: func(tsk *task.Task[uint64]) error {
|
Func: func(tsk *task.Task[uint64]) error {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
size, _ := strconv.ParseInt(file.Length, 10, 64)
|
size, _ := strconv.ParseInt(file.Length, 10, 64)
|
||||||
|
@ -12,11 +12,11 @@ import (
|
|||||||
|
|
||||||
func initDevData() {
|
func initDevData() {
|
||||||
err := operations.CreateStorage(context.Background(), model.Storage{
|
err := operations.CreateStorage(context.Background(), model.Storage{
|
||||||
VirtualPath: "/",
|
MountPath: "/",
|
||||||
Index: 0,
|
Index: 0,
|
||||||
Driver: "Local",
|
Driver: "Local",
|
||||||
Status: "",
|
Status: "",
|
||||||
Addition: `{"root_folder":"."}`,
|
Addition: `{"root_folder":"."}`,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to create storage: %+v", err)
|
log.Fatalf("failed to create storage: %+v", err)
|
||||||
|
@ -36,7 +36,7 @@ func _copy(ctx context.Context, srcObjPath, dstDirPath string) (bool, error) {
|
|||||||
}
|
}
|
||||||
// not in the same storage
|
// not in the same storage
|
||||||
CopyTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64]{
|
CopyTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64]{
|
||||||
Name: fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcStorage.GetStorage().VirtualPath, srcObjActualPath, dstStorage.GetStorage().VirtualPath, dstDirActualPath),
|
Name: fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcStorage.GetStorage().MountPath, srcObjActualPath, dstStorage.GetStorage().MountPath, dstDirActualPath),
|
||||||
Func: func(task *task.Task[uint64]) error {
|
Func: func(task *task.Task[uint64]) error {
|
||||||
return copyBetween2Storages(task, srcStorage, dstStorage, srcObjActualPath, dstDirActualPath)
|
return copyBetween2Storages(task, srcStorage, dstStorage, srcObjActualPath, dstDirActualPath)
|
||||||
},
|
},
|
||||||
@ -63,7 +63,7 @@ func copyBetween2Storages(t *task.Task[uint64], srcStorage, dstStorage driver.Dr
|
|||||||
srcObjPath := stdpath.Join(srcObjPath, obj.GetName())
|
srcObjPath := stdpath.Join(srcObjPath, obj.GetName())
|
||||||
dstObjPath := stdpath.Join(dstDirPath, obj.GetName())
|
dstObjPath := stdpath.Join(dstDirPath, obj.GetName())
|
||||||
CopyTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64]{
|
CopyTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64]{
|
||||||
Name: fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcStorage.GetStorage().VirtualPath, srcObjPath, dstStorage.GetStorage().VirtualPath, dstObjPath),
|
Name: fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcStorage.GetStorage().MountPath, srcObjPath, dstStorage.GetStorage().MountPath, dstObjPath),
|
||||||
Func: func(t *task.Task[uint64]) error {
|
Func: func(t *task.Task[uint64]) error {
|
||||||
return copyBetween2Storages(t, srcStorage, dstStorage, srcObjPath, dstObjPath)
|
return copyBetween2Storages(t, srcStorage, dstStorage, srcObjPath, dstObjPath)
|
||||||
},
|
},
|
||||||
@ -71,7 +71,7 @@ func copyBetween2Storages(t *task.Task[uint64], srcStorage, dstStorage driver.Dr
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CopyTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64]{
|
CopyTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64]{
|
||||||
Name: fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcStorage.GetStorage().VirtualPath, srcObjPath, dstStorage.GetStorage().VirtualPath, dstDirPath),
|
Name: fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcStorage.GetStorage().MountPath, srcObjPath, dstStorage.GetStorage().MountPath, dstDirPath),
|
||||||
Func: func(t *task.Task[uint64]) error {
|
Func: func(t *task.Task[uint64]) error {
|
||||||
return copyFileBetween2Storages(t, srcStorage, dstStorage, srcObjPath, dstDirPath)
|
return copyFileBetween2Storages(t, srcStorage, dstStorage, srcObjPath, dstDirPath)
|
||||||
},
|
},
|
||||||
|
@ -33,7 +33,7 @@ func putAsTask(dstDirPath string, file model.FileStreamer) error {
|
|||||||
file.SetReadCloser(tempFile)
|
file.SetReadCloser(tempFile)
|
||||||
}
|
}
|
||||||
UploadTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64]{
|
UploadTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64]{
|
||||||
Name: fmt.Sprintf("upload %s to [%s](%s)", file.GetName(), storage.GetStorage().VirtualPath, dstDirActualPath),
|
Name: fmt.Sprintf("upload %s to [%s](%s)", file.GetName(), storage.GetStorage().MountPath, dstDirActualPath),
|
||||||
Func: func(task *task.Task[uint64]) error {
|
Func: func(task *task.Task[uint64]) error {
|
||||||
return operations.Put(task.Ctx, storage, dstDirActualPath, file, nil)
|
return operations.Put(task.Ctx, storage, dstDirActualPath, file, nil)
|
||||||
},
|
},
|
||||||
|
@ -3,14 +3,14 @@ package model
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type Storage struct {
|
type Storage struct {
|
||||||
ID uint `json:"id" gorm:"primaryKey"` // unique key
|
ID uint `json:"id" gorm:"primaryKey"` // unique key
|
||||||
VirtualPath string `json:"virtual_path" gorm:"unique" binding:"required"` // must be standardized
|
MountPath string `json:"mount_path" gorm:"unique" binding:"required"` // must be standardized
|
||||||
Index int `json:"index"` // use to sort
|
Index int `json:"index"` // use to sort
|
||||||
Driver string `json:"driver"`
|
Driver string `json:"driver"` // driver used
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Addition string `json:"addition" gorm:"type:text"` // Additional information, defined in the corresponding driver
|
Addition string `json:"addition" gorm:"type:text"` // Additional information, defined in the corresponding driver
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
Modified time.Time `json:"modified"`
|
Modified time.Time `json:"modified"`
|
||||||
Sort
|
Sort
|
||||||
Proxy
|
Proxy
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ var filesCache = cache.NewMemCache(cache.WithShards[[]model.Obj](64))
|
|||||||
var filesG singleflight.Group[[]model.Obj]
|
var filesG singleflight.Group[[]model.Obj]
|
||||||
|
|
||||||
func ClearCache(storage driver.Driver, path string) {
|
func ClearCache(storage driver.Driver, path string) {
|
||||||
key := stdpath.Join(storage.GetStorage().VirtualPath, path)
|
key := stdpath.Join(storage.GetStorage().MountPath, path)
|
||||||
filesCache.Del(key)
|
filesCache.Del(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ func List(ctx context.Context, storage driver.Driver, path string, refresh ...bo
|
|||||||
if storage.Config().NoCache {
|
if storage.Config().NoCache {
|
||||||
return storage.List(ctx, dir)
|
return storage.List(ctx, dir)
|
||||||
}
|
}
|
||||||
key := stdpath.Join(storage.GetStorage().VirtualPath, path)
|
key := stdpath.Join(storage.GetStorage().MountPath, path)
|
||||||
if len(refresh) == 0 || !refresh[0] {
|
if len(refresh) == 0 || !refresh[0] {
|
||||||
if files, ok := filesCache.Get(key); ok {
|
if files, ok := filesCache.Get(key); ok {
|
||||||
return files, nil
|
return files, nil
|
||||||
@ -132,7 +132,7 @@ func Link(ctx context.Context, storage driver.Driver, path string, args model.Li
|
|||||||
if file.IsDir() {
|
if file.IsDir() {
|
||||||
return nil, nil, errors.WithStack(errs.NotFile)
|
return nil, nil, errors.WithStack(errs.NotFile)
|
||||||
}
|
}
|
||||||
key := stdpath.Join(storage.GetStorage().VirtualPath, path)
|
key := stdpath.Join(storage.GetStorage().MountPath, path)
|
||||||
if link, ok := linkCache.Get(key); ok {
|
if link, ok := linkCache.Get(key); ok {
|
||||||
return link, file, nil
|
return link, file, nil
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ func Put(ctx context.Context, storage driver.Driver, dstDirPath string, file mod
|
|||||||
log.Debugf("put file [%s] done", file.GetName())
|
log.Debugf("put file [%s] done", file.GetName())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// clear cache
|
// clear cache
|
||||||
key := stdpath.Join(storage.GetStorage().VirtualPath, dstDirPath)
|
key := stdpath.Join(storage.GetStorage().MountPath, dstDirPath)
|
||||||
filesCache.Del(key)
|
filesCache.Del(key)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -31,8 +31,8 @@ func GetStorageAndActualPath(rawPath string) (driver.Driver, string, error) {
|
|||||||
if storage == nil {
|
if storage == nil {
|
||||||
return nil, "", errors.Errorf("can't find storage with rawPath: %s", rawPath)
|
return nil, "", errors.Errorf("can't find storage with rawPath: %s", rawPath)
|
||||||
}
|
}
|
||||||
log.Debugln("use storage: ", storage.GetStorage().VirtualPath)
|
log.Debugln("use storage: ", storage.GetStorage().MountPath)
|
||||||
virtualPath := utils.GetActualVirtualPath(storage.GetStorage().VirtualPath)
|
virtualPath := utils.GetActualVirtualPath(storage.GetStorage().MountPath)
|
||||||
actualPath := strings.TrimPrefix(rawPath, virtualPath)
|
actualPath := strings.TrimPrefix(rawPath, virtualPath)
|
||||||
actualPath = ActualPath(storage.GetAddition(), actualPath)
|
actualPath = ActualPath(storage.GetAddition(), actualPath)
|
||||||
return storage, actualPath, nil
|
return storage, actualPath, nil
|
||||||
|
@ -32,7 +32,7 @@ func GetStorageByVirtualPath(virtualPath string) (driver.Driver, error) {
|
|||||||
// then instantiate corresponding driver and save it in memory
|
// then instantiate corresponding driver and save it in memory
|
||||||
func CreateStorage(ctx context.Context, storage model.Storage) error {
|
func CreateStorage(ctx context.Context, storage model.Storage) error {
|
||||||
storage.Modified = time.Now()
|
storage.Modified = time.Now()
|
||||||
storage.VirtualPath = utils.StandardizePath(storage.VirtualPath)
|
storage.MountPath = utils.StandardizePath(storage.MountPath)
|
||||||
var err error
|
var err error
|
||||||
// check driver first
|
// check driver first
|
||||||
driverName := storage.Driver
|
driverName := storage.Driver
|
||||||
@ -52,7 +52,7 @@ func CreateStorage(ctx context.Context, storage model.Storage) error {
|
|||||||
return errors.WithMessage(err, "failed init storage but storage is already created")
|
return errors.WithMessage(err, "failed init storage but storage is already created")
|
||||||
}
|
}
|
||||||
log.Debugf("storage %+v is created", storageDriver)
|
log.Debugf("storage %+v is created", storageDriver)
|
||||||
storagesMap.Store(storage.VirtualPath, storageDriver)
|
storagesMap.Store(storage.MountPath, storageDriver)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,15 +68,15 @@ func UpdateStorage(ctx context.Context, storage model.Storage) error {
|
|||||||
return errors.Errorf("driver cannot be changed")
|
return errors.Errorf("driver cannot be changed")
|
||||||
}
|
}
|
||||||
storage.Modified = time.Now()
|
storage.Modified = time.Now()
|
||||||
storage.VirtualPath = utils.StandardizePath(storage.VirtualPath)
|
storage.MountPath = utils.StandardizePath(storage.MountPath)
|
||||||
err = db.UpdateStorage(&storage)
|
err = db.UpdateStorage(&storage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "failed update storage in database")
|
return errors.WithMessage(err, "failed update storage in database")
|
||||||
}
|
}
|
||||||
storageDriver, err := GetStorageByVirtualPath(oldStorage.VirtualPath)
|
storageDriver, err := GetStorageByVirtualPath(oldStorage.MountPath)
|
||||||
if oldStorage.VirtualPath != storage.VirtualPath {
|
if oldStorage.MountPath != storage.MountPath {
|
||||||
// virtual path renamed, need to drop the storage
|
// virtual path renamed, need to drop the storage
|
||||||
storagesMap.Delete(oldStorage.VirtualPath)
|
storagesMap.Delete(oldStorage.MountPath)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "failed get storage driver")
|
return errors.WithMessage(err, "failed get storage driver")
|
||||||
@ -89,7 +89,7 @@ func UpdateStorage(ctx context.Context, storage model.Storage) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "failed init storage")
|
return errors.WithMessage(err, "failed init storage")
|
||||||
}
|
}
|
||||||
storagesMap.Store(storage.VirtualPath, storageDriver)
|
storagesMap.Store(storage.MountPath, storageDriver)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ func DeleteStorageById(ctx context.Context, id uint) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "failed get storage")
|
return errors.WithMessage(err, "failed get storage")
|
||||||
}
|
}
|
||||||
storageDriver, err := GetStorageByVirtualPath(storage.VirtualPath)
|
storageDriver, err := GetStorageByVirtualPath(storage.MountPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "failed get storage driver")
|
return errors.WithMessage(err, "failed get storage driver")
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ func DeleteStorageById(ctx context.Context, id uint) error {
|
|||||||
return errors.WithMessage(err, "failed delete storage in database")
|
return errors.WithMessage(err, "failed delete storage in database")
|
||||||
}
|
}
|
||||||
// delete the storage in the memory
|
// delete the storage in the memory
|
||||||
storagesMap.Delete(storage.VirtualPath)
|
storagesMap.Delete(storage.MountPath)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ func getStoragesByPath(path string) []driver.Driver {
|
|||||||
storages := make([]driver.Driver, 0)
|
storages := make([]driver.Driver, 0)
|
||||||
curSlashCount := 0
|
curSlashCount := 0
|
||||||
storagesMap.Range(func(key string, value driver.Driver) bool {
|
storagesMap.Range(func(key string, value driver.Driver) bool {
|
||||||
virtualPath := utils.GetActualVirtualPath(value.GetStorage().VirtualPath)
|
virtualPath := utils.GetActualVirtualPath(value.GetStorage().MountPath)
|
||||||
if virtualPath == "/" {
|
if virtualPath == "/" {
|
||||||
virtualPath = ""
|
virtualPath = ""
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ func getStoragesByPath(path string) []driver.Driver {
|
|||||||
})
|
})
|
||||||
// make sure the order is the same for same input
|
// make sure the order is the same for same input
|
||||||
sort.Slice(storages, func(i, j int) bool {
|
sort.Slice(storages, func(i, j int) bool {
|
||||||
return storages[i].GetStorage().VirtualPath < storages[j].GetStorage().VirtualPath
|
return storages[i].GetStorage().MountPath < storages[j].GetStorage().MountPath
|
||||||
})
|
})
|
||||||
return storages
|
return storages
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ func GetStorageVirtualFilesByPath(prefix string) []model.Obj {
|
|||||||
storages := storagesMap.Values()
|
storages := storagesMap.Values()
|
||||||
sort.Slice(storages, func(i, j int) bool {
|
sort.Slice(storages, func(i, j int) bool {
|
||||||
if storages[i].GetStorage().Index == storages[j].GetStorage().Index {
|
if storages[i].GetStorage().Index == storages[j].GetStorage().Index {
|
||||||
return storages[i].GetStorage().VirtualPath < storages[j].GetStorage().VirtualPath
|
return storages[i].GetStorage().MountPath < storages[j].GetStorage().MountPath
|
||||||
}
|
}
|
||||||
return storages[i].GetStorage().Index < storages[j].GetStorage().Index
|
return storages[i].GetStorage().Index < storages[j].GetStorage().Index
|
||||||
})
|
})
|
||||||
@ -192,10 +192,10 @@ func GetStorageVirtualFilesByPath(prefix string) []model.Obj {
|
|||||||
for _, v := range storages {
|
for _, v := range storages {
|
||||||
// TODO should save a balanced storage
|
// TODO should save a balanced storage
|
||||||
// balance storage
|
// balance storage
|
||||||
if utils.IsBalance(v.GetStorage().VirtualPath) {
|
if utils.IsBalance(v.GetStorage().MountPath) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
virtualPath := v.GetStorage().VirtualPath
|
virtualPath := v.GetStorage().MountPath
|
||||||
if len(virtualPath) <= len(prefix) {
|
if len(virtualPath) <= len(prefix) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ func GetBalancedStorage(path string) driver.Driver {
|
|||||||
case 1:
|
case 1:
|
||||||
return storages[0]
|
return storages[0]
|
||||||
default:
|
default:
|
||||||
virtualPath := utils.GetActualVirtualPath(storages[0].GetStorage().VirtualPath)
|
virtualPath := utils.GetActualVirtualPath(storages[0].GetStorage().MountPath)
|
||||||
cur, ok := balanceMap.Load(virtualPath)
|
cur, ok := balanceMap.Load(virtualPath)
|
||||||
i := 0
|
i := 0
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -25,9 +25,9 @@ func TestCreateStorage(t *testing.T) {
|
|||||||
storage model.Storage
|
storage model.Storage
|
||||||
isErr bool
|
isErr bool
|
||||||
}{
|
}{
|
||||||
{storage: model.Storage{Driver: "Local", VirtualPath: "/local", Addition: `{"root_folder":"."}`}, isErr: false},
|
{storage: model.Storage{Driver: "Local", MountPath: "/local", Addition: `{"root_folder":"."}`}, isErr: false},
|
||||||
{storage: model.Storage{Driver: "Local", VirtualPath: "/local", Addition: `{"root_folder":"."}`}, isErr: true},
|
{storage: model.Storage{Driver: "Local", MountPath: "/local", Addition: `{"root_folder":"."}`}, isErr: true},
|
||||||
{storage: model.Storage{Driver: "None", VirtualPath: "/none", Addition: `{"root_folder":"."}`}, isErr: true},
|
{storage: model.Storage{Driver: "None", MountPath: "/none", Addition: `{"root_folder":"."}`}, isErr: true},
|
||||||
}
|
}
|
||||||
for _, storage := range storages {
|
for _, storage := range storages {
|
||||||
err := operations.CreateStorage(context.Background(), storage.storage)
|
err := operations.CreateStorage(context.Background(), storage.storage)
|
||||||
@ -59,22 +59,22 @@ func TestGetStorageVirtualFilesByPath(t *testing.T) {
|
|||||||
func TestGetBalancedStorage(t *testing.T) {
|
func TestGetBalancedStorage(t *testing.T) {
|
||||||
setupStorages(t)
|
setupStorages(t)
|
||||||
storage := operations.GetBalancedStorage("/a/d/e")
|
storage := operations.GetBalancedStorage("/a/d/e")
|
||||||
if storage.GetStorage().VirtualPath != "/a/d/e" {
|
if storage.GetStorage().MountPath != "/a/d/e" {
|
||||||
t.Errorf("expected: /a/d/e, got: %+v", storage.GetStorage().VirtualPath)
|
t.Errorf("expected: /a/d/e, got: %+v", storage.GetStorage().MountPath)
|
||||||
}
|
}
|
||||||
storage = operations.GetBalancedStorage("/a/d/e")
|
storage = operations.GetBalancedStorage("/a/d/e")
|
||||||
if storage.GetStorage().VirtualPath != "/a/d/e.balance" {
|
if storage.GetStorage().MountPath != "/a/d/e.balance" {
|
||||||
t.Errorf("expected: /a/d/e.balance, got: %+v", storage.GetStorage().VirtualPath)
|
t.Errorf("expected: /a/d/e.balance, got: %+v", storage.GetStorage().MountPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupStorages(t *testing.T) {
|
func setupStorages(t *testing.T) {
|
||||||
var storages = []model.Storage{
|
var storages = []model.Storage{
|
||||||
{Driver: "Local", VirtualPath: "/a/b", Index: 0, Addition: `{"root_folder":"."}`},
|
{Driver: "Local", MountPath: "/a/b", Index: 0, Addition: `{"root_folder":"."}`},
|
||||||
{Driver: "Local", VirtualPath: "/a/c", Index: 1, Addition: `{"root_folder":"."}`},
|
{Driver: "Local", MountPath: "/a/c", Index: 1, Addition: `{"root_folder":"."}`},
|
||||||
{Driver: "Local", VirtualPath: "/a/d", Index: 2, Addition: `{"root_folder":"."}`},
|
{Driver: "Local", MountPath: "/a/d", Index: 2, Addition: `{"root_folder":"."}`},
|
||||||
{Driver: "Local", VirtualPath: "/a/d/e", Index: 3, Addition: `{"root_folder":"."}`},
|
{Driver: "Local", MountPath: "/a/d/e", Index: 3, Addition: `{"root_folder":"."}`},
|
||||||
{Driver: "Local", VirtualPath: "/a/d/e.balance", Index: 4, Addition: `{"root_folder":"."}`},
|
{Driver: "Local", MountPath: "/a/d/e.balance", Index: 4, Addition: `{"root_folder":"."}`},
|
||||||
}
|
}
|
||||||
for _, storage := range storages {
|
for _, storage := range storages {
|
||||||
err := operations.CreateStorage(context.Background(), storage)
|
err := operations.CreateStorage(context.Background(), storage)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user