Skip to content

Commit

Permalink
Use download_url() in language pack upgrader
Browse files Browse the repository at this point in the history
Fixes #30.
  • Loading branch information
swissspidy committed Aug 2, 2018
1 parent 710c821 commit 7198de2
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/WP_CLI/LanguagePackUpgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,14 @@ public function download_package( $package ) {
return $temp;
}

/*
* Download to a temporary file because piping from cURL to tar is flaky
* on MinGW (and probably in other environments too).
*/
$headers = array( 'Accept' => 'application/json' );
$options = array(
'timeout' => 600, // 10 minutes ought to be enough for everybody.
'filename' => $temp
);

$this->skin->feedback( 'downloading_package', $package );

/** @var \Requests_Response|null $req */
$req = Utils\http_request( 'GET', $package, null, $headers, $options );
if ( null !== $req && $req->status_code !== 200 ) {
return new \WP_Error( 'download_failed', $this->strings['download_failed'] );
$temp = download_url( $package, 600 ); // 10 minutes ought to be enough for everybody.

if ( is_wp_error( $temp ) ) {
return $temp;
}

$cache->import( $cache_key, $temp );

return $temp;
Expand Down

0 comments on commit 7198de2

Please sign in to comment.