vfs: fix errors when using > 260 char files in the cache in Windows

This makes the cache use UNC paths on Windows. This stops the cache
exploding when using > 260 character paths
This commit is contained in:
Nick Craig-Wood 2020-06-11 13:06:02 +01:00
parent 917cb4acb3
commit 28255f1bac

View file

@ -20,6 +20,7 @@ import (
"github.com/rclone/rclone/fs/hash" "github.com/rclone/rclone/fs/hash"
"github.com/rclone/rclone/fs/log" "github.com/rclone/rclone/fs/log"
"github.com/rclone/rclone/fs/operations" "github.com/rclone/rclone/fs/operations"
"github.com/rclone/rclone/lib/file"
"github.com/rclone/rclone/vfs/vfscommon" "github.com/rclone/rclone/vfs/vfscommon"
) )
@ -60,9 +61,9 @@ func New(ctx context.Context, fremote fs.Fs, opt *vfscommon.Options) (*Cache, er
} }
fRoot = strings.Replace(fRoot, ":", "", -1) fRoot = strings.Replace(fRoot, ":", "", -1)
} }
root := filepath.Join(config.CacheDir, "vfs", fremote.Name(), fRoot) root := file.UNCPath(filepath.Join(config.CacheDir, "vfs", fremote.Name(), fRoot))
fs.Debugf(nil, "vfs cache root is %q", root) fs.Debugf(nil, "vfs cache root is %q", root)
metaRoot := filepath.Join(config.CacheDir, "vfsMeta", fremote.Name(), fRoot) metaRoot := file.UNCPath(filepath.Join(config.CacheDir, "vfsMeta", fremote.Name(), fRoot))
fs.Debugf(nil, "vfs metadata cache root is %q", root) fs.Debugf(nil, "vfs metadata cache root is %q", root)
fcache, err := fscache.Get(root) fcache, err := fscache.Get(root)