Merge pull request #19439 from nextcloud/backport/19430/stable18

[stable18] disable timeout on app install via cli
This commit is contained in:
Roeland Jago Douma 2020-02-12 20:25:16 +01:00 committed by GitHub
commit 6954d3a50c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 11 deletions

View file

@ -70,6 +70,8 @@ class Installer {
private $apps = null; private $apps = null;
/** @var bool|null - for caching the result of the ready status */ /** @var bool|null - for caching the result of the ready status */
private $isInstanceReadyForUpdates = null; private $isInstanceReadyForUpdates = null;
/** @var bool */
private $isCLI;
/** /**
* @param AppFetcher $appFetcher * @param AppFetcher $appFetcher
@ -78,16 +80,20 @@ class Installer {
* @param ILogger $logger * @param ILogger $logger
* @param IConfig $config * @param IConfig $config
*/ */
public function __construct(AppFetcher $appFetcher, public function __construct(
AppFetcher $appFetcher,
IClientService $clientService, IClientService $clientService,
ITempManager $tempManager, ITempManager $tempManager,
ILogger $logger, ILogger $logger,
IConfig $config) { IConfig $config,
bool $isCLI
) {
$this->appFetcher = $appFetcher; $this->appFetcher = $appFetcher;
$this->clientService = $clientService; $this->clientService = $clientService;
$this->tempManager = $tempManager; $this->tempManager = $tempManager;
$this->logger = $logger; $this->logger = $logger;
$this->config = $config; $this->config = $config;
$this->isCLI = $isCLI;
} }
/** /**
@ -270,8 +276,9 @@ class Installer {
// Download the release // Download the release
$tempFile = $this->tempManager->getTemporaryFile('.tar.gz'); $tempFile = $this->tempManager->getTemporaryFile('.tar.gz');
$timeout = $this->isCLI ? 0 : 120;
$client = $this->clientService->newClient(); $client = $this->clientService->newClient();
$client->get($app['releases'][0]['download'], ['save_to' => $tempFile, 'timeout' => 120]); $client->get($app['releases'][0]['download'], ['save_to' => $tempFile, 'timeout' => $timeout]);
// Check if the signature actually matches the downloaded content // Check if the signature actually matches the downloaded content
$certificate = openssl_get_publickey($app['certificate']); $certificate = openssl_get_publickey($app['certificate']);

View file

@ -1272,7 +1272,8 @@ class Server extends ServerContainer implements IServerContainer {
$c->getHTTPClientService(), $c->getHTTPClientService(),
$c->getTempManager(), $c->getTempManager(),
$c->getLogger(), $c->getLogger(),
$c->getConfig() $c->getConfig(),
\OC::$CLI
); );
}); });

View file

@ -57,7 +57,8 @@ class InstallerTest extends TestCase {
\OC::$server->getHTTPClientService(), \OC::$server->getHTTPClientService(),
\OC::$server->getTempManager(), \OC::$server->getTempManager(),
\OC::$server->getLogger(), \OC::$server->getLogger(),
$config $config,
false
); );
$installer->removeApp(self::$appid); $installer->removeApp(self::$appid);
} }
@ -68,7 +69,8 @@ class InstallerTest extends TestCase {
$this->clientService, $this->clientService,
$this->tempManager, $this->tempManager,
$this->logger, $this->logger,
$this->config $this->config,
false
); );
} }
@ -78,7 +80,8 @@ class InstallerTest extends TestCase {
\OC::$server->getHTTPClientService(), \OC::$server->getHTTPClientService(),
\OC::$server->getTempManager(), \OC::$server->getTempManager(),
\OC::$server->getLogger(), \OC::$server->getLogger(),
\OC::$server->getConfig() \OC::$server->getConfig(),
false
); );
$installer->removeApp(self::$appid); $installer->removeApp(self::$appid);
\OC::$server->getConfig()->setSystemValue('appstoreenabled', $this->appstore); \OC::$server->getConfig()->setSystemValue('appstoreenabled', $this->appstore);
@ -101,7 +104,8 @@ class InstallerTest extends TestCase {
\OC::$server->getHTTPClientService(), \OC::$server->getHTTPClientService(),
\OC::$server->getTempManager(), \OC::$server->getTempManager(),
\OC::$server->getLogger(), \OC::$server->getLogger(),
\OC::$server->getConfig() \OC::$server->getConfig(),
false
); );
$this->assertNull(\OC::$server->getConfig()->getAppValue('testapp', 'enabled', null), 'Check that the app is not listed before installation'); $this->assertNull(\OC::$server->getConfig()->getAppValue('testapp', 'enabled', null), 'Check that the app is not listed before installation');
$this->assertSame('testapp', $installer->installApp(self::$appid)); $this->assertSame('testapp', $installer->installApp(self::$appid));