From 944f7da486708db3f4f4491cf7c6bc3ab919fa60 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 10 Apr 2017 15:46:35 -0700 Subject: [PATCH] (stable) 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 --- .../conduit/FileUploadChunkConduitAPIMethod.php | 15 ++++++++++----- .../files/storage/PhabricatorFile.php | 5 +++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php b/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php index 949bdde28a..b4d1a23a3f 100644 --- a/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php +++ b/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php @@ -61,15 +61,20 @@ final class FileUploadChunkConduitAPIMethod $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 // are only accessed through the storage engine. $chunk_data = PhabricatorFile::newFromFileData( $data, - array( - 'name' => $file->getMonogram().'.chunk-'.$chunk->getID(), - 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, - 'mime-type' => $mime_type, - )); + $params); $chunk->setDataFilePHID($chunk_data->getPHID())->save(); diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php index 4faecbd557..db15fb43e0 100644 --- a/src/applications/files/storage/PhabricatorFile.php +++ b/src/applications/files/storage/PhabricatorFile.php @@ -251,6 +251,11 @@ final class PhabricatorFile extends PhabricatorFileDAO $file->setMimeType('application/octet-stream'); $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) { $file->setContentHash($chunked_hash); } else {