aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming/lib
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2022-10-14 11:40:24 +0200
committerVincent Petry <vincent@nextcloud.com>2022-10-14 16:18:40 +0200
commitac21c631a61fbc7042c787a5feb0cb9aa489af91 (patch)
tree7a5784e903b20d909d9b75e0f039608b4f87de81 /apps/theming/lib
parenta8e90a03fcf4e960545c4926bb2a8895960d8fdb (diff)
downloadnextcloud-server-ac21c631a61fbc7042c787a5feb0cb9aa489af91.tar.gz
nextcloud-server-ac21c631a61fbc7042c787a5feb0cb9aa489af91.zip
Fix migration
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming/lib')
-rw-r--r--apps/theming/lib/Jobs/MigrateBackgroundImages.php28
1 files changed, 22 insertions, 6 deletions
diff --git a/apps/theming/lib/Jobs/MigrateBackgroundImages.php b/apps/theming/lib/Jobs/MigrateBackgroundImages.php
index 97806fa600a..b816a4c8775 100644
--- a/apps/theming/lib/Jobs/MigrateBackgroundImages.php
+++ b/apps/theming/lib/Jobs/MigrateBackgroundImages.php
@@ -34,6 +34,7 @@ use OCP\BackgroundJob\QueuedJob;
use OCP\Files\AppData\IAppDataFactory;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
+use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IConfig;
class MigrateBackgroundImages extends QueuedJob {
@@ -57,7 +58,6 @@ class MigrateBackgroundImages extends QueuedJob {
return;
}
- $themingData = $this->appDataFactory->get(Application::APP_ID);
$dashboardData = $this->appDataFactory->get('dashboard');
$userIds = $this->config->getUsersForUserValue('theming', 'background', 'custom');
@@ -79,11 +79,8 @@ class MigrateBackgroundImages extends QueuedJob {
// migration
$file = $dashboardData->getFolder($userId)->getFile('background.jpg');
- try {
- $targetDir = $themingData->getFolder($userId);
- } catch (NotFoundException $e) {
- $targetDir = $themingData->newFolder($userId);
- }
+ $targetDir = $this->getUserFolder($userId);
+
if (!$targetDir->fileExists('background.jpg')) {
$targetDir->newFile('background.jpg', $file->getContent());
}
@@ -104,4 +101,23 @@ class MigrateBackgroundImages extends QueuedJob {
$this->jobList->add(self::class);
}
}
+
+ /**
+ * Get the root location for users theming data
+ */
+ protected function getUserFolder(string $userId): ISimpleFolder {
+ $themingData = $this->appDataFactory->get(Application::APP_ID);
+
+ try {
+ $rootFolder = $themingData->getFolder('users');
+ } catch (NotFoundException $e) {
+ $rootFolder = $themingData->newFolder('users');
+ }
+
+ try {
+ return $rootFolder->getFolder($userId);
+ } catch (NotFoundException $e) {
+ return $rootFolder->newFolder($userId);
+ }
+ }
}