Files
Ferdinand Thiessen 7ce46be408 fix(encryption): keep version and size in sync for files not in the cache
A file written through a stream has no file cache entry until the caller
scans it, but both inputs of the block signature are read from that entry:
stream_close() can only bump `encryptedVersion` if the entry exists, while
the reader got version 0 instead of the 1 the blocks were signed with, and
filesize() returned the wrapped storage's ciphertext size, which moved the
'end' position marker to the wrong block. Reading such a file back - e.g.
moving a part file to a target on another storage - failed with
"Bad Signature".

Treat a missing version as 1 on read, and let the size tracked while
writing win over the wrapped storage's size even without a cache entry.
Also stop reading `encryptedVersion` off a missing source entry when
updating the encrypted version of a copy or rename.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2026-09-21 00:05:26 +02:00
..