Skip to content

Commit

Permalink
Add timeout argument for download update
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightprince committed Nov 19, 2023
1 parent 00df50a commit 34318ee
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/AutoUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,11 @@ protected function downloadCurl(string $url, int $timeout = 10)
* @throws DownloadException
* @throws Exception
*/
protected function downloadUpdate(string $updateUrl, string $updateFile): bool
protected function downloadUpdate(string $updateUrl, string $updateFile, int $timeout): bool
{
$this->log->info(sprintf('Downloading update "%s" to "%s"', $updateUrl, $updateFile));
if (function_exists('curl_version') && $this->isValidUrl($updateUrl)) {
$update = $this->downloadCurl($updateUrl);
$update = $this->downloadCurl($updateUrl, $timeout);
if ($update === false) {
return false;
}
Expand Down Expand Up @@ -862,7 +862,7 @@ protected function install(string $updateFile, bool $simulateInstall, string $ve
* @throws ParserException
* @throws InvalidArgumentException
*/
public function update(bool $simulateInstall = true, bool $deleteDownload = true)
public function update(bool $simulateInstall = true, bool $deleteDownload = true, int $timeout = 60)
{
$this->log->info('Trying to perform update');

Expand Down Expand Up @@ -907,7 +907,7 @@ public function update(bool $simulateInstall = true, bool $deleteDownload = true

// Download update
if (!is_file($updateFile)) {
if (!$this->downloadUpdate($update['url'], $updateFile)) {
if (!$this->downloadUpdate($update['url'], $updateFile, $timeout)) {
$this->log->critical(sprintf('Failed to download update from "%s" to "%s"!', $update['url'],
$updateFile));

Expand Down

0 comments on commit 34318ee

Please sign in to comment.