Repository navigation
Open
Labels
Description
Before you start
- I have searched the forum and the existing issues for this problem.
- I have tested with the latest beta or stable release and can still reproduce the problem.
- This is a reproducible bug, not a usage question (questions belong on the forum).
Associated forum post URL
What is the problem you are having with rclone?
When editing a file's tags in foobar2000 (a music player), sometimes (quite randomly) rclone throws the following:
2026/09/18 15:50:32 INFO : <album path>/temp-85B2B722123322D2716935308FE52144.tmp: vfs cache: queuing for upload in 5s
2026/09/18 15:50:32 INFO : <album path>/01. The Subway.flac: File.Rename failed in Cache: failed to rename in cache: <album path>\temp-85B2B722123322D2716935308FE52144.tmp to <album path>\01. The Subway.flac: rename <album path>\temp-85B2B722123322D2716935308FE52144.tmp <album path>\01. The Subway.flac: Accès refusé.
2026/09/18 15:50:32 INFO : <album path>/01. The Subway.flac: vfs cache: removed cache file as stale (remote deleted)
2026/09/18 15:50:37 INFO : <album path>/01. The Subway.flac: Copied (new)
2026/09/18 15:50:37 INFO : <album path>/01. The Subway.flac: vfs cache: upload succeeded try #1
This effectively results in the file being truncated to 0 inside the mount. The temporary file is kept inside the VFS cache and simply copying it to the mount usually fixes the edited file.
rclone version
rclone v1.75.1
- os/version: Microsoft Windows 11 Pro 25H2 25H2 (64 bit)
- os/kernel: 10.0.26200.9457 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.26.8
- go/linking: static
- go/tags: cmount
Operating system
Windows
Which cloud storage system are you using?
Pixeldrain
Output of rclone config redacted
[pixeldrainfs]
type = pixeldrain
api_key = XXX
global.disable_http2 = true
Env:
RCLONE_VOLNAME=Pixeldrain
RCLONE_VERBOSE=1
RCLONE_LINKS=true
RCLONE_VFS_CACHE_MODE=full
RCLONE_VFS_CACHE_MAX_AGE=3d
RCLONE_CACHE_DIR=C:\Users\<user>\AppData\Local\rclone\PixeldrainService
RCLONE_BUFFER_SIZE=4M
RCLONE_VFS_READ_AHEAD=128M
RCLONE_VFS_DISK_SPACE_TOTAL_SIZE=2T
RCLONE_EXCLUDE_FROM=C:\Users\<user>\AppData\Local\rclone\PixeldrainService\exclude-file.txtThe command you were trying to run
rclone mount pixeldrainfs P:A log from the command with the -vv flag
I couldn't reproduce it after setting RCLONE_VERBOSE=2. I will share it when it happens again.Anything else?
The forum post I shared is not my own but I do believe this is the same issue.
Activity
HarmfulBreeze commentedon Sep 18, 2026
Can't reproduce after trying out PR #9574 changes (rebased onto master).
Kurptas commentedon Sep 25, 2026
Independent reproduction + root cause for the same failure, on Windows 11 + WinFsp 2.2.26215, rclone v1.75.1 and current master, over an SFTP remote (a name-preserving server:
rclone serve sftp --local-encoding Raw), mount with--vfs-cache-mode full. The save action is exactly what your player does — write a temp file and rename it over the target — and, like you, I see the file end up truncated/empty while the temp file survives in the cache.The reason it needs a read first (i.e. "edit the file you just opened") is that the VFS keeps the cached file's descriptor open for clean items through the handle-caching grace period (
vfs/vfscache/item.go), and Windowsos.Rename(MoveFileEx) cannot replace a destination that is open — even when the handle was opened withFILE_SHARE_DELETE(verified with a ctypes experiment:os.replacefails withWinError 5for both anopen()handle and aCreateFileW(..., FILE_SHARE_DELETE)handle, and succeeds once closed). HenceFile.Rename failed in Cache: ... Access is denied, and then:vfs/file.go(File.rename) logged the failure at Info level and returned nil, so the FUSE layer saw success;vfs/vfscache/item.go(item.rename) had already setitem.name/item.oand re-targeted the pending write-back (writeback.Rename(id, newName)) before the file move, whileCache.renamereturned before moving the map key — so the item claims a name whose cache file does not exist;vfs/vfscache/item.go_store→fremote.NewObject/fcache.NewObject), which is theCopied (new)in your log; depending on which stale state wins you get a reverted file, a truncated one, or a 0-byte one (I got all three across timing variants).Timing variants I measured on the unpatched binary (same commands, only the delay between the read and the rename differed):
So the trigger is the open cache handle, not the remote backend.
PR #9574 addresses this (error propagation in
vfs/file.go+ a Windows rename withFILE_RENAME_POSIX_SEMANTICS | FILE_RENAME_REPLACE_IF_EXISTSinlib/file). I built the same two changes locally and confirmed the end-to-end result: with them, the editor-style save succeeds and the file is correct (noAccess is denied, noCopied (new)), on both v1.75.1 and master; with only the error propagation it fails loudly instead of losing data. Two things I found that #9574 does not cover, in case they matter for review:item.renamemust move the cache files before mutatingitem.name/item.o(and must not re-target the write-back on failure), andFile.renameshould roll back the node'sd/dPath/leafwhen the rename fails; otherwise the item/node and their files stay inconsistent. I have those plus a reload fix (vfs/vfscache/cache.gowalk()passes the OS-encoded path toCache.get(), so a dirty item is dropped on remount) in #9975; the reload fix alone is #9974, and I linked both to this issue so they show up in its timeline.Note for anyone whose filenames contain non-ASCII punctuation: that is a separate defect from this one (a non-identity
encodingon the remote makes a mount save land on a differently-quoted name). It is not part of the fix discussed here and I can file it separately if useful.vfs: fail instead of silently losing data when a cache rename fails
lib/file: add Rename which can replace an open file on Windows