Skip to content

Commit 0248910

Browse files
Altahrimbackportbot[bot]
authored andcommitted
fix(download): use mirror and don't always fallback to Nextcloud download server
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
1 parent 55d647a commit 0248910

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

index.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ public function checkForUpdate() {
159159
if ($version !== '' && $version !== $this->currentVersion) {
160160
$this->updateAvailable = true;
161161
$releaseChannel = $this->getCurrentReleaseChannel();
162-
$updateText = 'Update to ' . htmlentities($versionString) . ' available. (channel: "' . htmlentities($releaseChannel) . '")<br /><span class="light">Following file will be downloaded automatically:</span> <code class="light">' . (string)$response['url'] . '</code>';
162+
$downloadUrl = current($this->getDownloadURLs());
163+
$updateText = 'Update to ' . htmlentities($versionString) . ' available. (channel: "' . htmlentities($releaseChannel) . '")<br /><span class="light">Following file will be downloaded automatically:</span> <code class="light">' . $downloadUrl . '</code>';
163164

164165
// only show changelog link for stable releases (non-RC & non-beta)
165166
if (!preg_match('!(rc|beta)!i', $versionString)) {
@@ -555,10 +556,10 @@ private function getUpdateServerResponse(): array {
555556
*
556557
* @throws \Exception
557558
*/
558-
public function downloadUpdate(?string $url = null): void {
559+
public function downloadUpdate(string $url = ''): void {
559560
$this->silentLog('[info] downloadUpdate()');
560561

561-
if ($url) {
562+
if ($url !== '') {
562563
// If a URL is provided, use it directly
563564
$downloadURLs = [$url];
564565
} else {
@@ -599,7 +600,10 @@ public function downloadUpdate(?string $url = null): void {
599600
private function getDownloadURLs(): array {
600601
$response = $this->getUpdateServerResponse();
601602
$downloadURLs = [];
602-
if (!isset($response['downloads']) || !is_array($response['downloads'])) {
603+
604+
if (isset($response['downloads'])) {
605+
$response['downloads'] = (array)$response['downloads'];
606+
} else {
603607
if (isset($response['url']) && is_string($response['url'])) {
604608
// Compatibility with previous verison of updater_server
605609
$ext = pathinfo($response['url'], PATHINFO_EXTENSION);
@@ -610,6 +614,7 @@ private function getDownloadURLs(): array {
610614
throw new \Exception('Response from update server is missing download URLs');
611615
}
612616
}
617+
613618
foreach ($response['downloads'] as $format => $urls) {
614619
if (!$this->isAbleToDecompress($format)) {
615620
continue;

lib/Updater.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ public function checkForUpdate() {
141141
if ($version !== '' && $version !== $this->currentVersion) {
142142
$this->updateAvailable = true;
143143
$releaseChannel = $this->getCurrentReleaseChannel();
144-
$updateText = 'Update to ' . htmlentities($versionString) . ' available. (channel: "' . htmlentities($releaseChannel) . '")<br /><span class="light">Following file will be downloaded automatically:</span> <code class="light">' . (string)$response['url'] . '</code>';
144+
$downloadUrl = current($this->getDownloadURLs());
145+
$updateText = 'Update to ' . htmlentities($versionString) . ' available. (channel: "' . htmlentities($releaseChannel) . '")<br /><span class="light">Following file will be downloaded automatically:</span> <code class="light">' . $downloadUrl . '</code>';
145146

146147
// only show changelog link for stable releases (non-RC & non-beta)
147148
if (!preg_match('!(rc|beta)!i', $versionString)) {
@@ -537,10 +538,10 @@ private function getUpdateServerResponse(): array {
537538
*
538539
* @throws \Exception
539540
*/
540-
public function downloadUpdate(?string $url = null): void {
541+
public function downloadUpdate(string $url = ''): void {
541542
$this->silentLog('[info] downloadUpdate()');
542543

543-
if ($url) {
544+
if ($url !== '') {
544545
// If a URL is provided, use it directly
545546
$downloadURLs = [$url];
546547
} else {
@@ -581,7 +582,10 @@ public function downloadUpdate(?string $url = null): void {
581582
private function getDownloadURLs(): array {
582583
$response = $this->getUpdateServerResponse();
583584
$downloadURLs = [];
584-
if (!isset($response['downloads']) || !is_array($response['downloads'])) {
585+
586+
if (isset($response['downloads'])) {
587+
$response['downloads'] = (array)$response['downloads'];
588+
} else {
585589
if (isset($response['url']) && is_string($response['url'])) {
586590
// Compatibility with previous verison of updater_server
587591
$ext = pathinfo($response['url'], PATHINFO_EXTENSION);
@@ -592,6 +596,7 @@ private function getDownloadURLs(): array {
592596
throw new \Exception('Response from update server is missing download URLs');
593597
}
594598
}
599+
595600
foreach ($response['downloads'] as $format => $urls) {
596601
if (!$this->isAbleToDecompress($format)) {
597602
continue;

vendor/composer/autoload_classmap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@
160160
'Symfony\\Contracts\\Service\\ServiceProviderInterface' => $vendorDir . '/symfony/service-contracts/ServiceProviderInterface.php',
161161
'Symfony\\Contracts\\Service\\ServiceSubscriberInterface' => $vendorDir . '/symfony/service-contracts/ServiceSubscriberInterface.php',
162162
'Symfony\\Contracts\\Service\\ServiceSubscriberTrait' => $vendorDir . '/symfony/service-contracts/ServiceSubscriberTrait.php',
163+
'Symfony\\Contracts\\Service\\Test\\ServiceLocatorTest' => $vendorDir . '/symfony/service-contracts/Test/ServiceLocatorTest.php',
164+
'Symfony\\Contracts\\Service\\Test\\ServiceLocatorTestCase' => $vendorDir . '/symfony/service-contracts/Test/ServiceLocatorTestCase.php',
163165
'Symfony\\Polyfill\\Ctype\\Ctype' => $vendorDir . '/symfony/polyfill-ctype/Ctype.php',
164166
'Symfony\\Polyfill\\Intl\\Grapheme\\Grapheme' => $vendorDir . '/symfony/polyfill-intl-grapheme/Grapheme.php',
165167
'Symfony\\Polyfill\\Intl\\Normalizer\\Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Normalizer.php',

vendor/composer/autoload_static.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ class ComposerStaticInit936ba63ded5d1b8248cdb4d5673af0ea
250250
'Symfony\\Contracts\\Service\\ServiceProviderInterface' => __DIR__ . '/..' . '/symfony/service-contracts/ServiceProviderInterface.php',
251251
'Symfony\\Contracts\\Service\\ServiceSubscriberInterface' => __DIR__ . '/..' . '/symfony/service-contracts/ServiceSubscriberInterface.php',
252252
'Symfony\\Contracts\\Service\\ServiceSubscriberTrait' => __DIR__ . '/..' . '/symfony/service-contracts/ServiceSubscriberTrait.php',
253+
'Symfony\\Contracts\\Service\\Test\\ServiceLocatorTest' => __DIR__ . '/..' . '/symfony/service-contracts/Test/ServiceLocatorTest.php',
254+
'Symfony\\Contracts\\Service\\Test\\ServiceLocatorTestCase' => __DIR__ . '/..' . '/symfony/service-contracts/Test/ServiceLocatorTestCase.php',
253255
'Symfony\\Polyfill\\Ctype\\Ctype' => __DIR__ . '/..' . '/symfony/polyfill-ctype/Ctype.php',
254256
'Symfony\\Polyfill\\Intl\\Grapheme\\Grapheme' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/Grapheme.php',
255257
'Symfony\\Polyfill\\Intl\\Normalizer\\Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Normalizer.php',

0 commit comments

Comments
 (0)