mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 09:32:29 +08:00
vfs: make cache dir absolute before using it to fix path too long errors
If --cache-dir is passed in as a relative path, then rclone will not be able to turn it into a UNC path under Windows, which means that file names longer than 260 chars will fail when stored in the cache. This patch makes the --cache-dir path absolute before using it. See: https://forum.rclone.org/t/handling-of-long-paths-on-windows-260-characters/20913
This commit is contained in:
parent
816e68a274
commit
4f8ee736b1
|
@ -81,9 +81,14 @@ func New(ctx context.Context, fremote fs.Fs, opt *vfscommon.Options, avFn AddVir
|
|||
}
|
||||
fRoot = strings.Replace(fRoot, ":", "", -1)
|
||||
}
|
||||
root := file.UNCPath(filepath.Join(config.CacheDir, "vfs", fremote.Name(), fRoot))
|
||||
cacheDir := config.CacheDir
|
||||
cacheDir, err := filepath.Abs(cacheDir)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to make --cache-dir absolute")
|
||||
}
|
||||
root := file.UNCPath(filepath.Join(cacheDir, "vfs", fremote.Name(), fRoot))
|
||||
fs.Debugf(nil, "vfs cache: root is %q", root)
|
||||
metaRoot := file.UNCPath(filepath.Join(config.CacheDir, "vfsMeta", fremote.Name(), fRoot))
|
||||
metaRoot := file.UNCPath(filepath.Join(cacheDir, "vfsMeta", fremote.Name(), fRoot))
|
||||
fs.Debugf(nil, "vfs cache: metadata root is %q", root)
|
||||
|
||||
fcache, err := fscache.Get(ctx, root)
|
||||
|
|
Loading…
Reference in New Issue
Block a user