Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Shortcut to avoid file system setup when generating the logo URL
If an SVG is requested and the app config value for logoMime is set then the logo is there. Otherwise we need to check it and maybe also generate a PNG from the SVG (that's done in getImage() which needs to be called then).

Signed-off-by: Morris Jobke <[email protected]>
  • Loading branch information
MorrisJobke authored and backportbot[bot] committed Nov 9, 2020
commit cc777911c204118924602e4edc3b7b11fe176983
19 changes: 14 additions & 5 deletions apps/theming/lib/ThemingDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,20 @@ public function getColorPrimary() {
public function getLogo($useSvg = true): string {
$logo = $this->config->getAppValue('theming', 'logoMime', false);

$logoExists = true;
try {
$this->imageManager->getImage('logo', $useSvg);
} catch (\Exception $e) {
$logoExists = false;
// short cut to avoid setting up the filesystem just to check if the logo is there
//
// explanation: if an SVG is requested and the app config value for logoMime is set then the logo is there.
// otherwise we need to check it and maybe also generate a PNG from the SVG (that's done in getImage() which
// needs to be called then)
if ($useSvg === true && $logo !== false) {
$logoExists = true;
} else {
try {
$this->imageManager->getImage('logo', $useSvg);
$logoExists = true;
} catch (\Exception $e) {
$logoExists = false;
}
}

$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
Expand Down
6 changes: 0 additions & 6 deletions apps/theming/tests/ThemingDefaultsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
use OCP\App\IAppManager;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IConfig;
Expand Down Expand Up @@ -617,11 +616,6 @@ public function testGetLogoDefaultWithoutSvg() {
}

public function testGetLogoCustom() {
$file = $this->createMock(ISimpleFile::class);
$this->imageManager->expects($this->once())
->method('getImage')
->with('logo')
->willReturn($file);
$this->config
->expects($this->at(0))
->method('getAppValue')
Expand Down