Skip to content

Commit

Permalink
Merge pull request #25088 from nextcloud/fix/allow_app_updates_again
Browse files Browse the repository at this point in the history
Allow installing/updating of apps again
  • Loading branch information
rullzer authored Jan 12, 2021
2 parents 90c0e94 + 41c80d6 commit e44f275
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
18 changes: 12 additions & 6 deletions lib/private/Http/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ private function buildRequestOptions(array $options): array {
$options[RequestOptions::HEADERS]['Accept-Encoding'] = 'gzip';
}

// Fallback for save_to
if (isset($options['save_to'])) {
$options['sink'] = $options['save_to'];
unset($options['save_to']);
}

return $options;
}

Expand Down Expand Up @@ -218,7 +224,7 @@ protected function preventLocalAddress(string $uri, array $options): void {
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
Expand Down Expand Up @@ -249,7 +255,7 @@ public function get(string $uri, array $options = []): IResponse {
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
Expand Down Expand Up @@ -284,7 +290,7 @@ public function head(string $uri, array $options = []): IResponse {
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
Expand Down Expand Up @@ -324,7 +330,7 @@ public function post(string $uri, array $options = []): IResponse {
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
Expand Down Expand Up @@ -359,7 +365,7 @@ public function put(string $uri, array $options = []): IResponse {
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
Expand Down Expand Up @@ -394,7 +400,7 @@ public function delete(string $uri, array $options = []): IResponse {
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* 'timeout' => 5,
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function downloadApp($appId, $allowUnstable = false) {
$tempFile = $this->tempManager->getTemporaryFile('.tar.gz');
$timeout = $this->isCLI ? 0 : 120;
$client = $this->clientService->newClient();
$client->get($app['releases'][0]['download'], ['save_to' => $tempFile, 'timeout' => $timeout]);
$client->get($app['releases'][0]['download'], ['sink' => $tempFile, 'timeout' => $timeout]);

// Check if the signature actually matches the downloaded content
$certificate = openssl_get_publickey($app['certificate']);
Expand Down
12 changes: 6 additions & 6 deletions lib/public/Http/Client/IClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ interface IClient {
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* @return IResponse
Expand All @@ -80,7 +80,7 @@ public function get(string $uri, array $options = []): IResponse;
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* @return IResponse
Expand Down Expand Up @@ -110,7 +110,7 @@ public function head(string $uri, array $options = []): IResponse;
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* @return IResponse
Expand Down Expand Up @@ -140,7 +140,7 @@ public function post(string $uri, array $options = []): IResponse;
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* @return IResponse
Expand Down Expand Up @@ -170,7 +170,7 @@ public function put(string $uri, array $options = []): IResponse;
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* @return IResponse
Expand Down Expand Up @@ -200,7 +200,7 @@ public function delete(string $uri, array $options = []): IResponse;
* 'referer' => true, // add a Referer header
* 'protocols' => ['https'] // only allow https URLs
* ],
* 'save_to' => '/path/to/file', // save to a file or a stream
* 'sink' => '/path/to/file', // save to a file or a stream
* 'verify' => true, // bool or string to CA file
* 'debug' => true,
* @return IResponse
Expand Down
10 changes: 5 additions & 5 deletions tests/lib/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function testDownloadAppWithInvalidSignature() {
$client
->expects($this->once())
->method('get')
->with('https://example.com', ['save_to' => $realTmpFile, 'timeout' => 120]);
->with('https://example.com', ['sink' => $realTmpFile, 'timeout' => 120]);
$this->clientService
->expects($this->once())
->method('newClient')
Expand Down Expand Up @@ -432,7 +432,7 @@ public function testDownloadAppWithMoreThanOneFolderDownloaded() {
$client
->expects($this->once())
->method('get')
->with('https://example.com', ['save_to' => $realTmpFile, 'timeout' => 120]);
->with('https://example.com', ['sink' => $realTmpFile, 'timeout' => 120]);
$this->clientService
->expects($this->once())
->method('newClient')
Expand Down Expand Up @@ -515,7 +515,7 @@ public function testDownloadAppWithMismatchingIdentifier() {
$client
->expects($this->once())
->method('get')
->with('https://example.com', ['save_to' => $realTmpFile, 'timeout' => 120]);
->with('https://example.com', ['sink' => $realTmpFile, 'timeout' => 120]);
$this->clientService
->expects($this->once())
->method('newClient')
Expand Down Expand Up @@ -594,7 +594,7 @@ public function testDownloadAppSuccessful() {
$client
->expects($this->once())
->method('get')
->with('https://example.com', ['save_to' => $realTmpFile, 'timeout' => 120]);
->with('https://example.com', ['sink' => $realTmpFile, 'timeout' => 120]);
$this->clientService
->expects($this->at(0))
->method('newClient')
Expand Down Expand Up @@ -680,7 +680,7 @@ public function testDownloadAppWithDowngrade() {
$client
->expects($this->once())
->method('get')
->with('https://example.com', ['save_to' => $realTmpFile, 'timeout' => 120]);
->with('https://example.com', ['sink' => $realTmpFile, 'timeout' => 120]);
$this->clientService
->expects($this->at(1))
->method('newClient')
Expand Down

0 comments on commit e44f275

Please sign in to comment.