1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-26 00:32:41 +01: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; $conduit = $this->conduit;
$futures = array(); $futures = array();
foreach ($files as $key => $file) { foreach ($files as $key => $file) {
$params = array( $params = $this->getUploadParameters($file) + array(
'name' => $file->getName(),
'contentLength' => $file->getByteSize(), 'contentLength' => $file->getByteSize(),
'contentHash' => $file->getContentHash(), 'contentHash' => $file->getContentHash(),
); );
@ -127,11 +126,6 @@ final class ArcanistFileUploader extends Phobject {
$params['deleteAfterEpoch'] = $delete_after; $params['deleteAfterEpoch'] = $delete_after;
} }
$view_policy = $file->getViewPolicy();
if ($view_policy !== null) {
$params['viewPolicy'] = $view_policy;
}
$futures[$key] = $conduit->callMethod('file.allocate', $params); $futures[$key] = $conduit->callMethod('file.allocate', $params);
} }
@ -294,13 +288,29 @@ final class ArcanistFileUploader extends Phobject {
return $conduit->callMethodSynchronous( return $conduit->callMethodSynchronous(
'file.upload', 'file.upload',
array( $this->getUploadParameters($file) + array(
'name' => $file->getName(),
'data_base64' => base64_encode($data), '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. * Write a status message.
* *