diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/l10n/de_DE.js | 2 | ||||
-rw-r--r-- | lib/l10n/de_DE.json | 2 | ||||
-rw-r--r-- | lib/private/App/AppManager.php | 22 | ||||
-rw-r--r-- | lib/private/Files/Stream/SeekableHttpStream.php | 81 | ||||
-rw-r--r-- | lib/private/Installer.php | 3 | ||||
-rw-r--r-- | lib/private/Setup/AbstractDatabase.php | 8 | ||||
-rw-r--r-- | lib/private/Setup/OCI.php | 6 | ||||
-rw-r--r-- | lib/public/App/IAppManager.php | 17 |
8 files changed, 107 insertions, 34 deletions
diff --git a/lib/l10n/de_DE.js b/lib/l10n/de_DE.js index c92dcbfd12c..98cdc59ec8d 100644 --- a/lib/l10n/de_DE.js +++ b/lib/l10n/de_DE.js @@ -209,7 +209,7 @@ OC.L10N.register( "Login canceled by app" : "Anmeldung durch die App abgebrochen", "App \"%1$s\" cannot be installed because the following dependencies are not fulfilled: %2$s" : "Die App „%1$s“ kann nicht installiert werden, da die folgenden Abhängigkeiten nicht erfüllt sind: %2$s", "a safe home for all your data" : "ein sicherer Ort für all Ihre Daten", - "File is currently busy, please try again later" : "Die Datei ist in Benutzung, bitte versuchen Sie es später noch einmal", + "File is currently busy, please try again later" : "Die Datei ist in Benutzung, bitte später erneut versuchen.", "Cannot download file" : "Datei kann nicht heruntergeladen werden", "Application is not enabled" : "Die Anwendung ist nicht aktiviert", "Authentication error" : "Authentifizierungsfehler", diff --git a/lib/l10n/de_DE.json b/lib/l10n/de_DE.json index 607e7e06f80..a5911ebcb8a 100644 --- a/lib/l10n/de_DE.json +++ b/lib/l10n/de_DE.json @@ -207,7 +207,7 @@ "Login canceled by app" : "Anmeldung durch die App abgebrochen", "App \"%1$s\" cannot be installed because the following dependencies are not fulfilled: %2$s" : "Die App „%1$s“ kann nicht installiert werden, da die folgenden Abhängigkeiten nicht erfüllt sind: %2$s", "a safe home for all your data" : "ein sicherer Ort für all Ihre Daten", - "File is currently busy, please try again later" : "Die Datei ist in Benutzung, bitte versuchen Sie es später noch einmal", + "File is currently busy, please try again later" : "Die Datei ist in Benutzung, bitte später erneut versuchen.", "Cannot download file" : "Datei kann nicht heruntergeladen werden", "Application is not enabled" : "Die Anwendung ist nicht aktiviert", "Authentication error" : "Authentifizierungsfehler", diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index f154bd854ad..6d2fe51d0ed 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -13,6 +13,7 @@ * @author Julius Haertl <jus@bitgrid.net> * @author Julius Härtl <jus@bitgrid.net> * @author Lukas Reschke <lukas@statuscode.ch> + * @author Maxence Lange <maxence@artificial-owl.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> * @author Roeland Jago Douma <roeland@famdouma.nl> @@ -91,8 +92,8 @@ class AppManager implements IAppManager { /** @var string[] */ private $shippedApps; - /** @var string[] */ - private $alwaysEnabled; + private array $alwaysEnabled = []; + private array $defaultEnabled = []; /** @var array */ private $appInfos = []; @@ -574,6 +575,7 @@ class AppManager implements IAppManager { $content = json_decode(file_get_contents($shippedJson), true); $this->shippedApps = $content['shippedApps']; $this->alwaysEnabled = $content['alwaysEnabled']; + $this->defaultEnabled = $content['defaultEnabled']; } } @@ -584,4 +586,20 @@ class AppManager implements IAppManager { $this->loadShippedJson(); return $this->alwaysEnabled; } + + /** + * @inheritdoc + */ + public function isDefaultEnabled(string $appId): bool { + return (in_array($appId, $this->getDefaultEnabledApps())); + } + + /** + * @inheritdoc + */ + public function getDefaultEnabledApps():array { + $this->loadShippedJson(); + + return $this->defaultEnabled; + } } diff --git a/lib/private/Files/Stream/SeekableHttpStream.php b/lib/private/Files/Stream/SeekableHttpStream.php index 820a681bd07..df37fd29f42 100644 --- a/lib/private/Files/Stream/SeekableHttpStream.php +++ b/lib/private/Files/Stream/SeekableHttpStream.php @@ -32,7 +32,7 @@ use Icewind\Streams\Wrapper; class SeekableHttpStream implements File { private const PROTOCOL = 'httpseek'; - private static $registered = false; + private static bool $registered = false; /** * Registers the stream wrapper using the `httpseek://` url scheme @@ -73,24 +73,26 @@ class SeekableHttpStream implements File { /** @var callable */ private $openCallback; - /** @var resource */ + /** @var ?resource|closed-resource */ private $current; - /** @var int */ - private $offset = 0; - /** @var int */ - private $length = 0; + private int $offset = 0; + private int $length = 0; + private bool $needReconnect = false; - private function reconnect(int $start) { + private function reconnect(int $start): bool { + $this->needReconnect = false; $range = $start . '-'; - if ($this->current != null) { + if ($this->hasOpenStream()) { fclose($this->current); } - $this->current = ($this->openCallback)($range); + $stream = ($this->openCallback)($range); - if ($this->current === false) { + if ($stream === false) { + $this->current = null; return false; } + $this->current = $stream; $responseHead = stream_get_meta_data($this->current)['wrapper_data']; @@ -109,6 +111,7 @@ class SeekableHttpStream implements File { return preg_match('#^content-range:#i', $v) === 1; })); if (!$rangeHeaders) { + $this->current = null; return false; } $contentRange = $rangeHeaders[0]; @@ -119,6 +122,7 @@ class SeekableHttpStream implements File { $length = intval(explode('/', $range)[1]); if ($begin !== $start) { + $this->current = null; return false; } @@ -128,6 +132,28 @@ class SeekableHttpStream implements File { return true; } + /** + * @return ?resource + */ + private function getCurrent() { + if ($this->needReconnect) { + $this->reconnect($this->offset); + } + if (is_resource($this->current)) { + return $this->current; + } else { + return null; + } + } + + /** + * @return bool + * @psalm-assert-if-true resource $this->current + */ + private function hasOpenStream(): bool { + return is_resource($this->current); + } + public function stream_open($path, $mode, $options, &$opened_path) { $options = stream_context_get_options($this->context)[self::PROTOCOL]; $this->openCallback = $options['callback']; @@ -136,10 +162,10 @@ class SeekableHttpStream implements File { } public function stream_read($count) { - if (!$this->current) { + if (!$this->getCurrent()) { return false; } - $ret = fread($this->current, $count); + $ret = fread($this->getCurrent(), $count); $this->offset += strlen($ret); return $ret; } @@ -149,22 +175,34 @@ class SeekableHttpStream implements File { case SEEK_SET: if ($offset === $this->offset) { return true; + } else { + $this->offset = $offset; } - return $this->reconnect($offset); + break; case SEEK_CUR: if ($offset === 0) { return true; + } else { + $this->offset += $offset; } - return $this->reconnect($this->offset + $offset); + break; case SEEK_END: if ($this->length === 0) { return false; } elseif ($this->length + $offset === $this->offset) { return true; + } else { + $this->offset = $this->length + $offset; } - return $this->reconnect($this->length + $offset); + break; } - return false; + + if ($this->hasOpenStream()) { + fclose($this->current); + } + $this->current = null; + $this->needReconnect = true; + return true; } public function stream_tell() { @@ -172,25 +210,26 @@ class SeekableHttpStream implements File { } public function stream_stat() { - if (is_resource($this->current)) { - return fstat($this->current); + if ($this->getCurrent()) { + return fstat($this->getCurrent()); } else { return false; } } public function stream_eof() { - if (is_resource($this->current)) { - return feof($this->current); + if ($this->getCurrent()) { + return feof($this->getCurrent()); } else { return true; } } public function stream_close() { - if (is_resource($this->current)) { + if ($this->hasOpenStream()) { fclose($this->current); } + $this->current = null; } public function stream_write($data) { diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 86d933b6fbd..43c3db7c3fd 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -545,8 +545,7 @@ class Installer { if ($filename[0] !== '.' and is_dir($app_dir['path']."/$filename")) { if (file_exists($app_dir['path']."/$filename/appinfo/info.xml")) { if ($config->getAppValue($filename, "installed_version", null) === null) { - $info = OC_App::getAppInfo($filename); - $enabled = isset($info['default_enable']); + $enabled = $appManager->isDefaultEnabled($filename); if (($enabled || in_array($filename, $appManager->getAlwaysEnabledApps())) && $config->getAppValue($filename, 'enabled') !== 'no') { if ($softErrors) { diff --git a/lib/private/Setup/AbstractDatabase.php b/lib/private/Setup/AbstractDatabase.php index 5ee9548564c..6c67254deba 100644 --- a/lib/private/Setup/AbstractDatabase.php +++ b/lib/private/Setup/AbstractDatabase.php @@ -69,14 +69,14 @@ abstract class AbstractDatabase { public function validate($config) { $errors = []; if (empty($config['dbuser']) && empty($config['dbname'])) { - $errors[] = $this->trans->t("%s enter the database username and name.", [$this->dbprettyname]); + $errors[] = $this->trans->t("Enter the database username and name for %s", [$this->dbprettyname]); } elseif (empty($config['dbuser'])) { - $errors[] = $this->trans->t("%s enter the database username.", [$this->dbprettyname]); + $errors[] = $this->trans->t("Enter the database username for %s", [$this->dbprettyname]); } elseif (empty($config['dbname'])) { - $errors[] = $this->trans->t("%s enter the database name.", [$this->dbprettyname]); + $errors[] = $this->trans->t("Enter the database name for %s", [$this->dbprettyname]); } if (substr_count($config['dbname'], '.') >= 1) { - $errors[] = $this->trans->t("%s you may not use dots in the database name", [$this->dbprettyname]); + $errors[] = $this->trans->t("You cannot use dots in the database name %s", [$this->dbprettyname]); } return $errors; } diff --git a/lib/private/Setup/OCI.php b/lib/private/Setup/OCI.php index 2348aa8d47d..477561bbe2a 100644 --- a/lib/private/Setup/OCI.php +++ b/lib/private/Setup/OCI.php @@ -53,11 +53,11 @@ class OCI extends AbstractDatabase { public function validate($config) { $errors = []; if (empty($config['dbuser']) && empty($config['dbname'])) { - $errors[] = $this->trans->t("%s enter the database username and name.", [$this->dbprettyname]); + $errors[] = $this->trans->t("Enter the database username and name for %s", [$this->dbprettyname]); } elseif (empty($config['dbuser'])) { - $errors[] = $this->trans->t("%s enter the database username.", [$this->dbprettyname]); + $errors[] = $this->trans->t("Enter the database username for %s", [$this->dbprettyname]); } elseif (empty($config['dbname'])) { - $errors[] = $this->trans->t("%s enter the database name.", [$this->dbprettyname]); + $errors[] = $this->trans->t("Enter the database name for %s", [$this->dbprettyname]); } return $errors; } diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index e0b5c049290..f7c9d848099 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -84,6 +84,17 @@ interface IAppManager { public function isInstalled($appId); /** + * Check if an app should be enabled by default + * + * Notice: This actually checks if the app should be enabled by default + * and not if currently installed/enabled + * + * @param string $appId ID of the app + * @since 25.0.0 + */ + public function isDefaultEnabled(string $appId):bool; + + /** * Enable an app for every user * * @param string $appId @@ -179,6 +190,12 @@ interface IAppManager { public function getAlwaysEnabledApps(); /** + * @return string[] app IDs + * @since 25.0.0 + */ + public function getDefaultEnabledApps(): array; + + /** * @param \OCP\IGroup $group * @return String[] * @since 17.0.0 |