Repository navigation
Conversation
b5fd10d to
efa4ba1
Compare
|
I’m not knowledeable enough on files internals to review this. |
…aims AssemblyStream compares what it read from each chunk against the size that chunk reports, but it asks for that size again while streaming. Sabre\File::get() repairs a filecache entry that disagrees with the storage and refreshes the node on the way past, so a chunk that was short on storage ends up compared against its own repaired size, matches, and the assembled file is silently truncated. Snapshot the sizes when the stream is opened and compare against those. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
Encryption::writeStream() only closed the source and target streams when the copy returned. If the source throws part way through, both were left open and the encryption stream was closed during engine shutdown instead, where writing back into the storage layer is no longer safe and takes the process down. Close them in a finally, the way Common::writeStream() already does. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
… move The chunks are checked against the length the client declared before the move, but nothing checks what actually landed. An assembly cut short leaves the destination truncated while the response still reports the upload as a success. Compare the destination against the declared length once the move is done. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
…-length A failed write was only reported when the request declared a content-length to check against. The MOVE that assembles a chunked upload never declares one, so on object storage a write that the backend rejected was answered with 204 while the previous object was still in place - a lost update the client cannot see. A write that failed is a failure whether or not a size was declared. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
efa4ba1 to
222b54f
Compare
|
@come-nc split and pushed. |
…annot destroy the target The guard deciding whether a DAV write goes through a part file asked View::isCreatable() about the part file path itself. isCreatable() answers whether something can be created *inside* a path, so for a file that does not exist yet it is always false and the guard collapsed to "skip the part file whenever the target is updatable" - that is, for every overwrite. An upload interrupted during assembly then truncated the user's existing file in place, while oc_filecache kept asserting the previous size and etag, so no client had any reason to re-fetch until a later occ files:scan turned the divergence into a download of the empty file. Ask isCreatable() about the directory that will hold the part file instead, and keep the part file out of the two cases where it cannot stand in for the target: - Part file names were always hashed, although the commit introducing the hashing only meant to do so for names too long to fit. Encryption resolves a part file's key by stripping the .ocTransferId suffix, which only leads back to the target while the real name is kept, so a hashed name left an encrypted overwrite undecryptable. Hash only when the name would overflow the filesystem limit, and keep writing directly to the target when it must be. - A single file share maps the target and nothing else, so a part file named beside it lands on a different storage - the recipient's own, under their quota - rather than next to the file being written. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
222b54f to
4e2ef40
Compare
|
Thanks for this. I reported the same bug in #62321 (KeePass databases synced by Strongbox, truncated four times since July), and #62853 has the root-cause analysis, so this PR resolves those two as well. I verified the change from 4e2ef40 end to end on master with Apache and mod_php: a 300000-byte PUT over an existing 310279-byte file, connection cut after 100000 bytes. Without the change the file ends up at 98304 bytes. With it the file keeps its size and SHA-256, and a normal overwrite and file versions still work. I have been running that one line as a local patch on 34.0.5 and 35.0.2 since 30 October. In #62853 ChristophSGR also confirmed the bug on 34.0.2 and 35.0.2 with Enpass. Since this silently replaces existing files with truncated content, it would be great if someone familiar with the DAV upload path could review it. |
Fix #63071
Summary
The guard deciding whether a DAV write goes through a part file asked
View::isCreatable()about the part file path itself.isCreatable()answers whether something can be created inside a path, so for a file that does not exist yet it is always false and the guard collapsed to "skip the part file whenever the target is updatable" - that is, for every overwrite. An upload interrupted during assembly then truncated the user's existing file in place, whileoc_filecachekept asserting the previoussizeandetag, so no client had any reason to re-fetch until a laterocc files:scanturned the divergence intoa download of the empty file.
Ask
isCreatable()about the directory that will hold the part file instead.Restoring part files for overwrites uncovered three further problems, fixed here because the first fix is not safe without them:
Part file names were always hashed, although the commit introducing the hashing only meant to do so for names too long to fit. Encryption resolves a part file's key by stripping the
.ocTransferIdsuffix, which only leads back to the target while the real name is kept, so a hashed name left an encrypted overwrite undecryptable. Hash only when the name would overflow the filesystem limit, and keep writing directly to the target when it must be.AssemblyStreamcompared each chunk against a size it re-read while streaming, butSabre\File::get()repairs a stale filecache entry and refreshes the node, so a chunk short on storage compared equal to itself and the assembled file was silently truncated. Snapshot the sizes at stream_open.A failed storage write was reported as success whenever the request carried no content-length, which the assembly MOVE never does. On object storage that answered 204 while the previous object was still in place - a lost update the client could not detect.
Also verify the assembled file against
OC-Total-Lengthafter the move, and close both streams when an encrypted write fails: an encryption stream left open is only closed during engine shutdown, where writing back into thestorage layer crashes the process.
Checklist
3. to review, feature component)stable32)AI (if applicable)