diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2022-10-13 15:40:47 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2022-10-13 17:51:30 +0200 |
commit | 59e07102ed2cb54e5122d8c5ca05d3fa11dbc176 (patch) | |
tree | 458fc15ce9e9ecfdff773d69c17b3953beea4127 /apps/theming/lib/Service | |
parent | 4d98128e9a4c170efb7ae1e5e063df14844964a2 (diff) | |
download | nextcloud-server-59e07102ed2cb54e5122d8c5ca05d3fa11dbc176.tar.gz nextcloud-server-59e07102ed2cb54e5122d8c5ca05d3fa11dbc176.zip |
graceful background image handling
- fallback to background image from old location
- migrate background images to new location as insensitive job
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/theming/lib/Service')
-rw-r--r-- | apps/theming/lib/Service/BackgroundService.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/apps/theming/lib/Service/BackgroundService.php b/apps/theming/lib/Service/BackgroundService.php index 0614fe00357..36623735728 100644 --- a/apps/theming/lib/Service/BackgroundService.php +++ b/apps/theming/lib/Service/BackgroundService.php @@ -30,6 +30,7 @@ namespace OCA\Theming\Service; use InvalidArgumentException; use OC\User\NoUserException; use OCA\Theming\AppInfo\Application; +use OCP\Files\AppData\IAppDataFactory; use OCP\Files\File; use OCP\Files\IAppData; use OCP\Files\IRootFolder; @@ -133,20 +134,22 @@ class BackgroundService { private IAppData $appData; private IConfig $config; private string $userId; + private IAppDataFactory $appDataFactory; public function __construct( - IRootFolder $rootFolder, - IAppData $appData, - IConfig $config, - ?string $userId + IRootFolder $rootFolder, + IAppDataFactory $appDataFactory, + IConfig $config, + ?string $userId ) { if ($userId === null) { return; } $this->rootFolder = $rootFolder; - $this->appData = $appData; + $this->appData = $appDataFactory->get(Application::APP_ID); $this->config = $config; $this->userId = $userId; + $this->appDataFactory = $appDataFactory; } public function setDefaultBackground(): void { @@ -193,6 +196,11 @@ class BackgroundService { try { return $this->getAppDataFolder()->getFile('background.jpg'); } catch (NotFoundException | NotPermittedException $e) { + try { + // Fallback can be removed in 26 + $dashboardFolder = $this->appDataFactory->get('dashboard'); + return $dashboardFolder->getFolder($this->userId)->getFile('background.jpg'); + } catch (\Throwable $t) {} } } return null; |