mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Remove some old code handling the absence of the file.uploadhash
Conduit method
Summary: The `file.uploadhash` method was added a long time ago (in D4899). It should be safe to assume that this method exists on most installs. Test Plan: N/A Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D11118
This commit is contained in:
parent
f8be9d7737
commit
f86a70f411
1 changed files with 26 additions and 38 deletions
|
@ -2504,47 +2504,35 @@ EOTEXT
|
||||||
|
|
||||||
echo pht('Uploading %d files...', count($need_upload))."\n";
|
echo pht('Uploading %d files...', count($need_upload))."\n";
|
||||||
|
|
||||||
// Now we're ready to upload the actual file data. If possible, we'll just
|
$hash_futures = array();
|
||||||
// transmit a hash of the file instead of the actual file data. If the data
|
foreach ($need_upload as $key => $spec) {
|
||||||
// already exists, Phabricator can share storage. Check if we can use
|
$hash_futures[$key] = $this->getConduit()->callMethod(
|
||||||
// "file.uploadhash" yet (i.e., if the server is up to date enough).
|
'file.uploadhash',
|
||||||
// TODO: Drop this check once we bump the protocol version.
|
array(
|
||||||
$conduit_methods = $this->getConduit()->callMethodSynchronous(
|
'name' => $spec['name'],
|
||||||
'conduit.query',
|
'hash' => sha1($spec['data']),
|
||||||
array());
|
));
|
||||||
$can_use_hash_upload = isset($conduit_methods['file.uploadhash']);
|
}
|
||||||
|
|
||||||
if ($can_use_hash_upload) {
|
$futures = id(new FutureIterator($hash_futures))
|
||||||
$hash_futures = array();
|
->limit(8);
|
||||||
foreach ($need_upload as $key => $spec) {
|
foreach ($futures as $key => $future) {
|
||||||
$hash_futures[$key] = $this->getConduit()->callMethod(
|
$type = $need_upload[$key]['type'];
|
||||||
'file.uploadhash',
|
$change = $need_upload[$key]['change'];
|
||||||
array(
|
$name = $need_upload[$key]['name'];
|
||||||
'name' => $spec['name'],
|
|
||||||
'hash' => sha1($spec['data']),
|
$phid = null;
|
||||||
));
|
try {
|
||||||
|
$phid = $future->resolve();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// Just try uploading normally if the hash upload failed.
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$futures = id(new FutureIterator($hash_futures))
|
if ($phid) {
|
||||||
->limit(8);
|
$change->setMetadata("{$type}:binary-phid", $phid);
|
||||||
foreach ($futures as $key => $future) {
|
unset($need_upload[$key]);
|
||||||
$type = $need_upload[$key]['type'];
|
echo pht("Uploaded '%s' (%s).", $name, $type)."\n";
|
||||||
$change = $need_upload[$key]['change'];
|
|
||||||
$name = $need_upload[$key]['name'];
|
|
||||||
|
|
||||||
$phid = null;
|
|
||||||
try {
|
|
||||||
$phid = $future->resolve();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
// Just try uploading normally if the hash upload failed.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($phid) {
|
|
||||||
$change->setMetadata("{$type}:binary-phid", $phid);
|
|
||||||
unset($need_upload[$key]);
|
|
||||||
echo pht("Uploaded '%s' (%s).", $name, $type)."\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue