mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
In "Download Raw Diff", engage the chunk engine to handle 8MB+ changes
Summary: Fixes T13313. The "Download Raw Diff" workflow in Differential currently uses an older way of interacting with Files that doesn't engage the chunk engine and can't handle 8MB+ files. Update to `IteratorFileUploadSource` -- we're still passing in a single giant blob, but this approach can be chunked. This will still break somewhere north of 8MB (it will break at 2GB with the PHP string limit if nowhere sooner, since we're putting the entire raw diff in `$raw_diff` rather than using a rope/stream) but will likely survive diffs in the hundreds-of-megabytes range for now. Test Plan: - Added `str_repeat('x', 1024 * 1024 * 9)` to the `$raw_diff` to create a 9MB+ diff. - Configured file storage with no engine explicitly configured for >8MB chunks (i.e., "reasonably"). - Clicked "Download Raw Diff". - Before: misleading file storage engine error ("no engine can store this file"). - After: large, raw diff response. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13313 Differential Revision: https://secure.phabricator.com/D20579
This commit is contained in:
parent
2bc045bab8
commit
14b076578f
1 changed files with 10 additions and 14 deletions
|
@ -1033,12 +1033,6 @@ final class DifferentialRevisionViewController
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Note this code is somewhat similar to the buildPatch method in
|
||||
* @{class:DifferentialReviewRequestMail}.
|
||||
*
|
||||
* @return @{class:AphrontRedirectResponse}
|
||||
*/
|
||||
private function buildRawDiffResponse(
|
||||
DifferentialRevision $revision,
|
||||
array $changesets,
|
||||
|
@ -1100,15 +1094,17 @@ final class DifferentialRevisionViewController
|
|||
}
|
||||
$file_name .= 'diff';
|
||||
|
||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||
$file = PhabricatorFile::newFromFileData(
|
||||
$raw_diff,
|
||||
array(
|
||||
'name' => $file_name,
|
||||
'ttl.relative' => phutil_units('24 hours in seconds'),
|
||||
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
|
||||
));
|
||||
$iterator = new ArrayIterator(array($raw_diff));
|
||||
|
||||
$source = id(new PhabricatorIteratorFileUploadSource())
|
||||
->setName($file_name)
|
||||
->setMIMEType('text/plain')
|
||||
->setRelativeTTL(phutil_units('24 hours in seconds'))
|
||||
->setViewPolicy(PhabricatorPolicies::POLICY_NOONE)
|
||||
->setIterator($iterator);
|
||||
|
||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||
$file = $source->uploadFile();
|
||||
$file->attachToObject($revision->getPHID());
|
||||
unset($unguarded);
|
||||
|
||||
|
|
Loading…
Reference in a new issue