diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-10-13 20:10:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-13 20:10:57 +0200 |
commit | c0c0387b8ea4d5281d5c5f04304bced8e3a5f733 (patch) | |
tree | 1eb7d3103278d13d0644eda68012ea0d1b39a80b /apps/theming/lib/Service | |
parent | b28757fddc90f753412bfe80baa1964e7ae912db (diff) | |
parent | 59e07102ed2cb54e5122d8c5ca05d3fa11dbc176 (diff) | |
download | nextcloud-server-c0c0387b8ea4d5281d5c5f04304bced8e3a5f733.tar.gz nextcloud-server-c0c0387b8ea4d5281d5c5f04304bced8e3a5f733.zip |
Merge pull request #34461 from nextcloud/fix/migrate-background
Fix missing background on upgrade
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; |