1
mirror of https://github.com/rclone/rclone synced 2024-12-24 15:43:45 +01:00

union: refactor to use fspath.SplitFs instead of fs.ParseRemote #4996

This commit is contained in:
Nick Craig-Wood 2021-02-10 14:32:44 +00:00
parent 3761cf68b4
commit f17d7c0012

View File

@ -14,6 +14,7 @@ import (
"github.com/pkg/errors"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/cache"
"github.com/rclone/rclone/fs/fspath"
)
var (
@ -62,7 +63,7 @@ type Entry interface {
// New creates a new Fs based on the
// string formatted `type:root_path(:ro/:nc)`
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 {
return nil, err
}
@ -83,10 +84,8 @@ func New(ctx context.Context, remote, root string, cacheTime time.Duration) (*Fs
f.creatable = false
fsPath = fsPath[0 : len(fsPath)-3]
}
if configName != "local" {
fsPath = configName + ":" + fsPath
}
rFs, err := cache.Get(ctx, fsPath)
remote = configName + fsPath
rFs, err := cache.Get(ctx, remote)
if err != nil && err != fs.ErrorIsFile {
return nil, err
}