1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 16:22:42 +01:00

Fix two minor issues with "arc download"

Summary:
Ref T12651. Ran into these during D17799:

  - Use `getStatusCode()` to put the actual status code into the message.
  - If we fail but wrote an empty file to reserve the filename, clean it up.

Test Plan:
  - Faked the error, `phlog()`'d the exception.
  - Saw sensible exception message.
  - Saw empty file get cleaned up.

Reviewers: chad, amckinley

Reviewed By: chad

Maniphest Tasks: T12651

Differential Revision: https://secure.phabricator.com/D17800
This commit is contained in:
epriestley 2017-04-27 16:17:04 -07:00
parent 5d0f5afca8
commit 27b51e6192

View file

@ -83,6 +83,7 @@ EOTEXT
$display_name = 'F'.$id;
$is_show = $this->show;
$save_as = $this->saveAs;
$path = null;
try {
$file = $conduit->callMethodSynchronous(
@ -186,7 +187,7 @@ EOTEXT
throw new Exception(
pht(
'Got HTTP %d status response, expected HTTP 200.',
$status));
$status->getStatusCode()));
}
if (strlen($data)) {
@ -232,6 +233,14 @@ EOTEXT
return 0;
} catch (Exception $ex) {
// If we created an empty file, clean it up.
if (!$is_show) {
if ($path !== null) {
Filesystem::remove($path);
}
}
// If we fail for any reason, fall back to the older mechanism using
// "file.info" and "file.download".
}