From: kwadwo Date: Sun, 17 Feb 2013 22:30:43 +0000 (-0800) Subject: Arc diff tries to upload files it knows about using a content hash rather than transf... X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=8692587921f7debba5f3fb2edac73eeabf9f93c3;p=arcanist.git Arc diff tries to upload files it knows about using a content hash rather than transfering data. Summary: Arc diff will hash file data and try to upload the file using upload by hash rather than transferring data. If it is unable, it defaults to its normal behavior Attempts to upload file by hash, use regular upload method otherwise Test Plan: Figure out how to arc diff to my local install and look at the behavior Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, mehrapulkit Differential Revision: https://secure.phabricator.com/D4968 --- diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 8c42e912..f6ccb932 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -1128,7 +1128,6 @@ EOTEXT list($version, $key) = explode('-', $key, 2); $change = $changes[$key]; $name = basename($change->getCurrentPath()); - try { $guid = $future->resolve(); $change->setMetadata($version.':binary-phid', $guid); @@ -1169,6 +1168,20 @@ EOTEXT echo "Uploading {$desc} '{$name}' ({$mime_type}, {$size} bytes)...\n"; + // Reuse storage if possible + // Try to upload file using content hash + $contentHash = sha1($data); + $call_result = $this->getConduit()->callMethodSynchronous( + 'file.uploadhash', + array( + 'hash' => $contentHash, + 'name' => $name, + )); + if ($call_result) { + $result['future'] = new ImmediateFuture($call_result); + return $result; + } + $result['future'] = $this->getConduit()->callMethod( 'file.upload', array(