public static function downloadPatch($url, $destination) { if ($downloaded = _drush_download_file($url, $destination, TRUE)) { if (!filesize($downloaded)) { throw new Exception("Remote patch {$url} downloaded as empty file {$destination}."); } else { drush_log(dt('Remote patch @url downloaded to @file.', array('@url' => $url, '@file' => $downloaded))); return $downloaded; } } else { throw new Exception("Unable to download or fetch remote patch from {$url} and save to {$destination}."); } }
/** * Download a backup. * * @param array $backup * An array from apiGetSiteEnvBackups(). * @param string $destination * The path to the destination. * * @return string * The full path to the downloaded backup. */ public function apiDownloadBackup($backup, $destination) { // See Drush's package_handler_download_project(). $destination_path = $destination . DIRECTORY_SEPARATOR . $backup['filename']; $path = _drush_download_file($backup['url'], $destination_path, 31556926); if ($path || drush_get_context('DRUSH_SIMULATE')) { return $destination_path; } else { return drush_set_error('SWITCHBOARD_PANTHEON_BACKUP_DL_FAIL', dt('Unable to download!')); } }