HomePhabricator

Fix some issues with Diffusion file data limits

Description

Fix some issues with Diffusion file data limits

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.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18885

Details

Provenance
epriestleyAuthored on Jan 19 2018, 10:11 PM
epriestleyPushed on Jan 22 2018, 7:52 PM
Reviewer
amckinley
Differential Revision
D18885: Fix some issues with Diffusion file data limits
Parents
rPc63768044559: Show related objects on daemon worker task queue detail pages
Branches
Unknown
Tags
Unknown
Build Status
Buildable 19119
Build 25816: Run Core Tests