vfs: fix the cache failing to upload symlinks when --links was specified

Before this change, if --vfs-cache-mode writes or above was set and
--links was in use, when a symlink was saved then the VFS failed to
upload it. This meant when the VFS was restarted the link wasn't there
any more.

This was caused by the local backend, which we use to manage the VFS
cache, picking up the global --links flag.

This patch makes sure that the internal instantations of the local
backend in the VFS cache don't ever use the --links flag or the
--local-links flag even if specified on the command line.

Fixes #8367
This commit is contained in:
Nick Craig-Wood 2025-02-10 17:13:59 +00:00
parent 8997993a30
commit b5e72e2fc3

View File

@ -227,7 +227,10 @@ func (c *Cache) createItemDir(name string) (string, error) {
// getBackend gets a backend for a cache root dir
func getBackend(ctx context.Context, parentPath string, name string, relativeDirPath string) (fs.Fs, error) {
path := fmt.Sprintf(":local,encoding='%v':%s/%s/%s", encoder.OS, parentPath, name, relativeDirPath)
// Make sure we turn off the global links flag as it overrides the backend specific one
ctx, ci := fs.AddConfig(ctx)
ci.Links = false
path := fmt.Sprintf(":local,encoding='%v',links=false:%s/%s/%s", encoder.OS, parentPath, name, relativeDirPath)
return fscache.Get(ctx, path)
}