simplify download error message

This commit is contained in:
crazywhalecc 2023-10-23 20:12:47 +08:00
parent 8a70da6291
commit 9b9644fe63
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 102 additions and 97 deletions

View File

@ -59,7 +59,7 @@ class DownloadCommand extends BaseCommand
*/ */
public function handle(): int public function handle(): int
{ {
// 删除旧资源 try {
if ($this->getOption('clean')) { if ($this->getOption('clean')) {
logger()->warning('You are doing some operations that not recoverable: removing directories below'); logger()->warning('You are doing some operations that not recoverable: removing directories below');
logger()->warning(SOURCE_PATH); logger()->warning(SOURCE_PATH);
@ -104,7 +104,6 @@ class DownloadCommand extends BaseCommand
// use openssl 1.1 // use openssl 1.1
if ($this->getOption('with-openssl11')) { if ($this->getOption('with-openssl11')) {
logger()->debug('Using openssl 1.1'); logger()->debug('Using openssl 1.1');
// 手动修改配置
Config::$source['openssl']['regex'] = '/href="(?<file>openssl-(?<version>1.[^"]+)\.tar\.gz)\"/'; Config::$source['openssl']['regex'] = '/href="(?<file>openssl-(?<version>1.[^"]+)\.tar\.gz)\"/';
} }
@ -154,10 +153,16 @@ class DownloadCommand extends BaseCommand
Downloader::downloadSource($source, Config::getSource($source)); Downloader::downloadSource($source, Config::getSource($source));
} }
} }
// 打印拉取资源用时
$time = round(microtime(true) - START_TIME, 3); $time = round(microtime(true) - START_TIME, 3);
logger()->info('Download complete, used ' . $time . ' s !'); logger()->info('Download complete, used ' . $time . ' s !');
return static::SUCCESS; return static::SUCCESS;
} catch (DownloaderException $e) {
logger()->error($e->getMessage());
return static::FAILURE;
} catch (WrongUsageException $e) {
logger()->critical($e->getMessage());
return static::FAILURE;
}
} }
private function downloadFromZip(string $path): int private function downloadFromZip(string $path): int

View File

@ -335,7 +335,7 @@ class Downloader
logger()->warning('Deleting download file: ' . $filename); logger()->warning('Deleting download file: ' . $filename);
unlink(DOWNLOAD_PATH . '/' . $filename); unlink(DOWNLOAD_PATH . '/' . $filename);
} }
throw $e; throw new DownloaderException('Download failed! ' . $e->getMessage());
} }
} }