Return Diffusion diffs through Files, not directly over Conduit
Summary: Fixes T10423. Ref T11524. This changes `diffusion.rawdiffquery` to return a file PHID instead of a blob of data. This is better in general, but particularly better for huge diffs (as in T10423) and diffs with non-utf8 data (as in T10423). Test Plan: - Used `bin/differential extract` to extract a latin1 diff, got a clean diff. - Used `bin/repository reparse --herald` to rerun herald on a latin1 diff, got a clean result. - Pushed latin1 diffs to test commit hooks. - Triggered the the too large / too slow logic. - Viewed latin1 diffs in Diffusion. - Used "blame past this change" in Diffusion to hit the `before` logic. Reviewers: chad Reviewed By: chad Subscribers: eadler Maniphest Tasks: T10423, T11524 Differential Revision: https://secure.phabricator.com/D16460
This commit is contained in:
@@ -1027,24 +1027,26 @@ final class DiffusionCommitController extends DiffusionController {
|
||||
}
|
||||
|
||||
private function buildRawDiffResponse(DiffusionRequest $drequest) {
|
||||
$raw_diff = $this->callConduitWithDiffusionRequest(
|
||||
$diff_info = $this->callConduitWithDiffusionRequest(
|
||||
'diffusion.rawdiffquery',
|
||||
array(
|
||||
'commit' => $drequest->getCommit(),
|
||||
'path' => $drequest->getPath(),
|
||||
));
|
||||
|
||||
$file = PhabricatorFile::buildFromFileDataOrHash(
|
||||
$raw_diff,
|
||||
array(
|
||||
'name' => $drequest->getCommit().'.diff',
|
||||
'ttl' => (60 * 60 * 24),
|
||||
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
|
||||
));
|
||||
$file_phid = $diff_info['filePHID'];
|
||||
|
||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||
$file->attachToObject($drequest->getRepository()->getPHID());
|
||||
unset($unguarded);
|
||||
$file = id(new PhabricatorFileQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withPHIDs(array($file_phid))
|
||||
->executeOne();
|
||||
if (!$file) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Failed to load file ("%s") returned by "%s".',
|
||||
$file_phid,
|
||||
'diffusion.rawdiffquery'));
|
||||
}
|
||||
|
||||
return $file->getRedirectResponse();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user