]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Arc diff tries to upload files it knows about using a content hash rather than transf...
authorkwadwo <kwadwon@gmail.com>
Sun, 17 Feb 2013 22:30:43 +0000 (14:30 -0800)
committerepriestley <git@epriestley.com>
Sun, 17 Feb 2013 22:30:43 +0000 (14:30 -0800)
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

src/workflow/ArcanistDiffWorkflow.php

index 8c42e9129022ec12ef1cd4dd1edeb2ac135750a6..f6ccb932549f4b3ad7bba9a0bb3f07a961b44c31 100644 (file)
@@ -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(