mirror of
https://github.com/rclone/rclone
synced 2024-11-21 22:50:16 +01:00
union: refactor to use fspath.SplitFs instead of fs.ParseRemote #4996
This commit is contained in:
parent
3761cf68b4
commit
f17d7c0012
@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rclone/rclone/fs"
|
"github.com/rclone/rclone/fs"
|
||||||
"github.com/rclone/rclone/fs/cache"
|
"github.com/rclone/rclone/fs/cache"
|
||||||
|
"github.com/rclone/rclone/fs/fspath"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -62,7 +63,7 @@ type Entry interface {
|
|||||||
// New creates a new Fs based on the
|
// New creates a new Fs based on the
|
||||||
// string formatted `type:root_path(:ro/:nc)`
|
// string formatted `type:root_path(:ro/:nc)`
|
||||||
func New(ctx context.Context, remote, root string, cacheTime time.Duration) (*Fs, error) {
|
func New(ctx context.Context, remote, root string, cacheTime time.Duration) (*Fs, error) {
|
||||||
_, configName, fsPath, err := fs.ParseRemote(remote)
|
configName, fsPath, err := fspath.SplitFs(remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -83,10 +84,8 @@ func New(ctx context.Context, remote, root string, cacheTime time.Duration) (*Fs
|
|||||||
f.creatable = false
|
f.creatable = false
|
||||||
fsPath = fsPath[0 : len(fsPath)-3]
|
fsPath = fsPath[0 : len(fsPath)-3]
|
||||||
}
|
}
|
||||||
if configName != "local" {
|
remote = configName + fsPath
|
||||||
fsPath = configName + ":" + fsPath
|
rFs, err := cache.Get(ctx, remote)
|
||||||
}
|
|
||||||
rFs, err := cache.Get(ctx, fsPath)
|
|
||||||
if err != nil && err != fs.ErrorIsFile {
|
if err != nil && err != fs.ErrorIsFile {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user