Page MenuHomePhabricator

Fix some issues with Diffusion file data limits
ClosedPublic

Authored by epriestley on Jan 19 2018, 10:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 17, 10:42 AM
Unknown Object (File)
Thu, Dec 12, 1:33 AM
Unknown Object (File)
Sun, Dec 8, 6:51 PM
Unknown Object (File)
Thu, Dec 5, 7:23 PM
Unknown Object (File)
Mon, Dec 2, 1:59 AM
Unknown Object (File)
Nov 23 2024, 7:39 AM
Unknown Object (File)
Oct 26 2024, 6:54 AM
Unknown Object (File)
Oct 15 2024, 12:16 AM
Subscribers
None

Details

Summary

See https://discourse.phabricator-community.org/t/files-created-from-repository-contents-slightly-over-one-chunk-in-size-are-truncated-to-exactly-one-chunk-in-size/988/1. Three issues here:

  • When we finish reading git cat-file ... or whatever, we can end up with more than one chunk worth of bytes left in the internal buffer if the read is fast. Use while instead of if to make sure we write the whole buffer.
  • Limiting output with setStdoutSizeLimit() isn't really a reliable way to limit the size if we're also reading from the buffer. It's also pretty indirect and confusing. Instead, just let the FileUploadSource explicitly implement a byte limit in a straightforward way.
  • We weren't setting the time limit correctly on the main path.

Overall, this could cause >4MB files to "write" as 4MB files, with the rest of the file left in the UploadSource buffer. Since these files were technically under the limit, they could return as valid. This was intermittent.

Test Plan
  • Pushed a ~4.2MB file.
  • Reloaded Diffusion a bunch, sometimes saw the while/if buffer race and produce a 4MB file with a prompt to download it. (Other times, the buffer worked right and the page just says "this file is too big, sorry").
  • Applied patches.
  • Reloaded Diffusion a bunch, no longer saw bad behavior or truncated files.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable