Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gofile, googlephotos: fix truncated files being uploaded successfully when the source ends early - #9787

Open
r0h1tb wants to merge 2 commits into
rclone:masterfrom
r0h1tb:fix/truncated-uploads-sweep
Open

r0h1tb wants to merge 2 commits into
rclone:masterfrom
r0h1tb:fix/truncated-uploads-sweep

Conversation

@r0h1tb

@r0h1tb r0h1tb commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

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-Length and never check how
much of it arrived.

gofile

Update posts the source as a multipart body with no Content-Length and nothing in the
function looks at the size, so a source that stops short is accepted by the server and
setMetaData runs on the result as a success.

googlephotos

Update sends the source to /uploads with X-Goog-Upload-Protocol: raw and no
Content-Length. A short source still returns an upload token, and the media item is then
created 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

filefabric looked like the same shape but is already covered: it sets
opts.ContentLength when the size is known and rejects a mismatch afterwards with
uploader.FileSize != size. Left alone.

box (#9785) and yandex (#9786) are the same class and are sent separately since they are
independent of these two.

Verification

go build ./..., go test on both backends and golangci-lint run on both (0 issues) all
pass. RCLONE_CONFIG=/notfound go test ./... is unchanged from master: cmd/gitannex and
cmd/serve/s3 fail identically before and after on my machine (no git-annex or minio
binary locally). I have no gofile or Google Photos remote, so the backend integration tests
have not been run against a real remote.

r0h1tb added 2 commits August 17, 2026 16:20
…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 CAOShurong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants