1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Correct two parameter strictness issues with file uploads

Summary:
Fixes T12531. Strictness fallout from adding typechecking in D17616.

  - `chunkedHash` is not a real parameter, so the new typechecking was unhappy about it.
  - `mime-type` no longer allows `null`.

Test Plan:
  - Ran `arc upload --conduit-uri ... 12MB.zero` on a 12MB file full of zeroes.
  - Before patch: badness, failure, fallback to one-shot uploads.
  - After patch: success and glory.

Reviewers: chad

Subscribers: joshuaspence

Maniphest Tasks: T12531

Differential Revision: https://secure.phabricator.com/D17651
This commit is contained in:
epriestley 2017-04-10 15:46:35 -07:00
parent 49132b884b
commit a7a068f84c
2 changed files with 15 additions and 5 deletions

View file

@ -61,15 +61,20 @@ final class FileUploadChunkConduitAPIMethod
$mime_type = 'application/octet-stream'; $mime_type = 'application/octet-stream';
} }
$params = array(
'name' => $file->getMonogram().'.chunk-'.$chunk->getID(),
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
);
if ($mime_type !== null) {
$params['mime-type'] = 'application/octet-stream';
}
// NOTE: These files have a view policy which prevents normal access. They // NOTE: These files have a view policy which prevents normal access. They
// are only accessed through the storage engine. // are only accessed through the storage engine.
$chunk_data = PhabricatorFile::newFromFileData( $chunk_data = PhabricatorFile::newFromFileData(
$data, $data,
array( $params);
'name' => $file->getMonogram().'.chunk-'.$chunk->getID(),
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
'mime-type' => $mime_type,
));
$chunk->setDataFilePHID($chunk_data->getPHID())->save(); $chunk->setDataFilePHID($chunk_data->getPHID())->save();

View file

@ -251,6 +251,11 @@ final class PhabricatorFile extends PhabricatorFileDAO
$file->setMimeType('application/octet-stream'); $file->setMimeType('application/octet-stream');
$chunked_hash = idx($params, 'chunkedHash'); $chunked_hash = idx($params, 'chunkedHash');
// Get rid of this parameter now; we aren't passing it any further down
// the stack.
unset($params['chunkedHash']);
if ($chunked_hash) { if ($chunked_hash) {
$file->setContentHash($chunked_hash); $file->setContentHash($chunked_hash);
} else { } else {