1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-09-19 16:38:51 +02:00

Fix handling of View Policy in CLI upload workflow for small, unique files

Summary:
Ref T7148. When uploading files from the CLI with a particular view policy, we may not respect it if the file is unique (so the data isn't already known) and small (so it doesn't invoke the chunker).

This is rare (and may never have happened outside of testing) because:

  - production dumps are always larger than the minimum chunk size;
  - only cluster stuff uses `setViewPolicy()`;
  - the default policy is "Administrators" anyway, which is safe.

However, I caught it in local testing, so fix it up.

Test Plan: Used `bin/host upload --file ...` to upload a small, unique file. Verified it uploaded with the correct custom view policy ("No One") rather than the default view policy ("Administrators").

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7148

Differential Revision: https://secure.phabricator.com/D16408
This commit is contained in:
epriestley 2016-08-17 06:55:48 -07:00
parent d0957c3441
commit 6507be27ae

View file

@ -116,8 +116,7 @@ final class ArcanistFileUploader extends Phobject {
$conduit = $this->conduit;
$futures = array();
foreach ($files as $key => $file) {
$params = array(
'name' => $file->getName(),
$params = $this->getUploadParameters($file) + array(
'contentLength' => $file->getByteSize(),
'contentHash' => $file->getContentHash(),
);
@ -127,11 +126,6 @@ final class ArcanistFileUploader extends Phobject {
$params['deleteAfterEpoch'] = $delete_after;
}
$view_policy = $file->getViewPolicy();
if ($view_policy !== null) {
$params['viewPolicy'] = $view_policy;
}
$futures[$key] = $conduit->callMethod('file.allocate', $params);
}
@ -294,13 +288,29 @@ final class ArcanistFileUploader extends Phobject {
return $conduit->callMethodSynchronous(
'file.upload',
array(
'name' => $file->getName(),
$this->getUploadParameters($file) + array(
'data_base64' => base64_encode($data),
));
}
/**
* Get common parameters for file uploads.
*/
private function getUploadParameters(ArcanistFileDataRef $file) {
$params = array(
'name' => $file->getName(),
);
$view_policy = $file->getViewPolicy();
if ($view_policy !== null) {
$params['viewPolicy'] = $view_policy;
}
return $params;
}
/**
* Write a status message.
*