gofile, googlephotos: fix truncated files being uploaded successfully when the source ends early - #9787
Open
r0h1tb wants to merge 2 commits into
Open
gofile, googlephotos: fix truncated files being uploaded successfully when the source ends early#9787r0h1tb wants to merge 2 commits into
r0h1tb wants to merge 2 commits into
Conversation
…ce ends early The upload sent the source as a multipart body with no Content-Length, so a source that supplied fewer bytes than its declared size was accepted by the server and reported as a success with a truncated file stored. Count the bytes actually read and fail the upload if they do not match the declared size.
…e source ends early The upload sent the source to the raw upload endpoint with no Content-Length, so a source that supplied fewer bytes than its declared size still returned an upload token and the media item was created from truncated data. Count the bytes actually read and fail the upload if they do not match the declared size.
CAOShurong
approved these changes
Aug 23, 2026
CAOShurong
left a comment
Contributor
There was a problem hiding this comment.
Consistent application of the truncated-upload guard to gofile and googlephotos backends. The \size >= 0\ check before comparison is a nice touch — it correctly handles backends that report unknown sizes as -1. This brings these backends in line with the same data-integrity guarantee being added elsewhere.
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.
Continues the "source ends early" sweep (5d05754 sia, a2baa97 pikpak, e1bf940 filelu,
7357fb8 internetarchive, 884b28c azurefiles, 18fa445 compress), for the two remaining
backends I could find that stream the source with no
Content-Lengthand never check howmuch of it arrived.
gofile
Updateposts the source as a multipart body with noContent-Lengthand nothing in thefunction looks at the size, so a source that stops short is accepted by the server and
setMetaDataruns on the result as a success.googlephotos
Updatesends the source to/uploadswithX-Goog-Upload-Protocol: rawand noContent-Length. A short source still returns an upload token, and the media item is thencreated from truncated data.
Both now count the bytes read and fail if they do not match the declared size, matching the
sia fix.
Not included
filefabriclooked like the same shape but is already covered: it setsopts.ContentLengthwhen the size is known and rejects a mismatch afterwards withuploader.FileSize != size. Left alone.box(#9785) andyandex(#9786) are the same class and are sent separately since they areindependent of these two.
Verification
go build ./...,go teston both backends andgolangci-lint runon both (0 issues) allpass.
RCLONE_CONFIG=/notfound go test ./...is unchanged from master:cmd/gitannexandcmd/serve/s3fail identically before and after on my machine (nogit-annexorminiobinary locally). I have no gofile or Google Photos remote, so the backend integration tests
have not been run against a real remote.