Repository navigation
Conversation
This was referenced Sep 25, 2026
walk() hands the OS encoded name of a cache file to Cache.get(), but that is a remote (standard) encoded namespace: get/newItem/item all take remote paths. So on a cache reload items whose names the OS encoding changes (a fullwidth colon, a trailing space, a literal quote rune, ...) were created under the OS encoded name and their cache and metadata files were then looked up under a twice encoded, and therefore missing, path. The visible effect is that a pending write back for such a file is silently dropped when the mount is restarted with a warm cache, and the cache item is known by the wrong name (and accounted as 0 bytes). Fix by converting the walked name back to remote encoding, as New() already does for the cache parent path. ASCII names are unaffected as the conversion is the identity for them. Add a regression test covering fullwidth and trailing space names plus an ASCII control.
Author
|
Rebased onto current For the record, the other lint failure in the earlier run — Local checks after the rebase: The workflow runs for this push are |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
vfs/vfscache/cache.gowalk()hands the OS-encoded cache-directory path toCache.get()/reload(), whose contract (see the comments onget/newItem/Item, andNew()'s ownfromOSPatha few lines above) requires a remote name. So when an existing cache directory is re-walked (remount, cache reuse), items are created under an OS-encoded key that is not the remote name, and their cache/metadata files are looked up under a twice-encoded, non-existent path.Consequences measured on Windows (WinFsp, SFTP remote,
--vfs-cache-mode full):--vfs-write-back 1h, kill the mount while the item is dirty (its metadata file hasDirty=trueand 13 B of data), remount the same--cache-dir:reload()finds nothing to resume, nothing is uploaded and the remote keeps the old (9 B) content. With this fix the edit is resumed and uploaded (13 B).vfs cache: cleaned: objects 1 (was 1) in use 0, to upload 0, total size 0for a 6 B cached object, and the item is logged under its OS-encoded name (A‛:B.txt) instead of its remote name (A:B.txt).:/?, a trailing space): those get a‛(QuoteRune) prefix in the cache key.Change
name = fromOSPath(name)inwalk(), i.e. the same conversionNew()already performs atcache.go.walk()'s only caller isreload(), which uses the name as a cache key and log prefix, andfromOSPathis the identity for names the OS encoding never changes (ASCII), so nothing else can be affected and no quoting semantics change.Test
TestCacheReloadOSEncodedName(vfs/vfscache/cache_test.go): builds a cache, creates an item under a risky remote name, marks it dirty with the write-back pending, reopens the cache withWriteBack=0and asserts (1) the reloaded item set is exactly[{name: <the remote name>}]and not an OS-encoded key, (2)get(name)finds it, (3) the pending edit reached the remote under the unchanged name.Fails before this change for
A:B.txt,A?B.txtand a trailing-space name (three different encoder rules), passes after; the ASCII row passes in both. TheA‛B.txtrow is skipped on purpose: the encoder is not invertible for names that already containQuoteRune(OS.FromStandardNamemaps bothA‛:B.txtandA‛‛:B.txtto the same value), so recovering those needs the remote name persisted in the item metadata — a separate, larger change.go build,go vet, andgo test ./vfs/... ./lib/encoder/...are clean.