aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/AppFramework/DependencyInjection/DIContainer.php5
-rw-r--r--lib/private/Avatar.php23
-rw-r--r--lib/private/AvatarManager.php29
-rw-r--r--lib/private/Files/AppData/AppData.php131
-rw-r--r--lib/private/Files/AppData/Factory.php50
-rw-r--r--lib/private/Files/SimpleFS/SimpleFile.php115
-rw-r--r--lib/private/Files/SimpleFS/SimpleFolder.php87
-rw-r--r--lib/private/Repair.php5
-rw-r--r--lib/private/Repair/NC11/MoveAvatarBackgroundJob.php104
-rw-r--r--lib/private/Repair/NC11/MoveAvatars.php64
-rw-r--r--lib/private/Server.php18
-rw-r--r--lib/private/legacy/util.php12
12 files changed, 611 insertions, 32 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php
index 20351d1321c..b6f8d8f458d 100644
--- a/lib/private/AppFramework/DependencyInjection/DIContainer.php
+++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php
@@ -46,6 +46,7 @@ use OC\AppFramework\Utility\SimpleContainer;
use OC\Core\Middleware\TwoFactorMiddleware;
use OCP\AppFramework\IApi;
use OCP\AppFramework\IAppContainer;
+use OCP\Files\IAppData;
class DIContainer extends SimpleContainer implements IAppContainer {
@@ -164,6 +165,10 @@ class DIContainer extends SimpleContainer implements IAppContainer {
return $this->getServer()->getHTTPClientService();
});
+ $this->registerService(IAppData::class, function (SimpleContainer $c) {
+ return $this->getServer()->getAppDataDir($c->query('AppName'));
+ });
+
$this->registerService('OCP\\IGroupManager', function($c) {
return $this->getServer()->getGroupManager();
});
diff --git a/lib/private/Avatar.php b/lib/private/Avatar.php
index 9e8bd0136c2..c3a068701df 100644
--- a/lib/private/Avatar.php
+++ b/lib/private/Avatar.php
@@ -29,10 +29,10 @@
namespace OC;
use OC\User\User;
-use OCP\Files\Folder;
-use OCP\Files\File;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
+use OCP\Files\SimpleFS\ISimpleFile;
+use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IAvatar;
use OCP\IConfig;
use OCP\IImage;
@@ -45,7 +45,7 @@ use OCP\ILogger;
*/
class Avatar implements IAvatar {
- /** @var Folder */
+ /** @var ISimpleFolder */
private $folder;
/** @var IL10N */
private $l;
@@ -59,13 +59,13 @@ class Avatar implements IAvatar {
/**
* constructor
*
- * @param Folder $folder The folder where the avatars are
+ * @param ISimpleFolder $folder The folder where the avatars are
* @param IL10N $l
* @param User $user
* @param ILogger $logger
* @param IConfig $config
*/
- public function __construct(Folder $folder,
+ public function __construct(ISimpleFolder $folder,
IL10N $l,
$user,
ILogger $logger,
@@ -98,7 +98,8 @@ class Avatar implements IAvatar {
* @return bool
*/
public function exists() {
- return $this->folder->nodeExists('avatar.jpg') || $this->folder->nodeExists('avatar.png');
+
+ return $this->folder->fileExists('avatar.jpg') || $this->folder->fileExists('avatar.png');
}
/**
@@ -170,15 +171,15 @@ class Avatar implements IAvatar {
}
try {
- $file = $this->folder->get($path);
+ $file = $this->folder->getFile($path);
} catch (NotFoundException $e) {
if ($size <= 0) {
throw new NotFoundException;
}
$avatar = new OC_Image();
- /** @var File $file */
- $file = $this->folder->get('avatar.' . $ext);
+ /** @var ISimpleFile $file */
+ $file = $this->folder->getFile('avatar.' . $ext);
$avatar->loadFromData($file->getContent());
if ($size !== -1) {
$avatar->resize($size);
@@ -201,9 +202,9 @@ class Avatar implements IAvatar {
* @throws NotFoundException
*/
private function getExtension() {
- if ($this->folder->nodeExists('avatar.jpg')) {
+ if ($this->folder->fileExists('avatar.jpg')) {
return 'jpg';
- } elseif ($this->folder->nodeExists('avatar.png')) {
+ } elseif ($this->folder->fileExists('avatar.png')) {
return 'png';
}
throw new NotFoundException;
diff --git a/lib/private/AvatarManager.php b/lib/private/AvatarManager.php
index df3247b8f00..b8c6c2a1eb6 100644
--- a/lib/private/AvatarManager.php
+++ b/lib/private/AvatarManager.php
@@ -27,13 +27,12 @@
namespace OC;
-use OCP\Files\Folder;
+use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\IAvatarManager;
use OCP\IConfig;
use OCP\ILogger;
use OCP\IUserManager;
-use OCP\Files\IRootFolder;
use OCP\IL10N;
/**
@@ -44,8 +43,8 @@ class AvatarManager implements IAvatarManager {
/** @var IUserManager */
private $userManager;
- /** @var IRootFolder */
- private $rootFolder;
+ /** @var IAppData */
+ private $appData;
/** @var IL10N */
private $l;
@@ -60,19 +59,19 @@ class AvatarManager implements IAvatarManager {
* AvatarManager constructor.
*
* @param IUserManager $userManager
- * @param IRootFolder $rootFolder
+ * @param IAppData $appData
* @param IL10N $l
* @param ILogger $logger
* @param IConfig $config
*/
public function __construct(
IUserManager $userManager,
- IRootFolder $rootFolder,
+ IAppData $appData,
IL10N $l,
ILogger $logger,
IConfig $config) {
$this->userManager = $userManager;
- $this->rootFolder = $rootFolder;
+ $this->appData = $appData;
$this->l = $l;
$this->logger = $logger;
$this->config = $config;
@@ -95,20 +94,12 @@ class AvatarManager implements IAvatarManager {
// sanitize userID - fixes casing issue (needed for the filesystem stuff that is done below)
$userId = $user->getUID();
- /*
- * Fix for #22119
- * Basically we do not want to copy the skeleton folder.
- *
- * For unit test purposes this is ignored when run in PHPUnit.
- */
- if(!defined('PHPUNIT_RUN')) {
- \OC\Files\Filesystem::initMountPoints($userId);
+ try {
+ $folder = $this->appData->getFolder($userId);
+ } catch (NotFoundException $e) {
+ $folder = $this->appData->newFolder($userId);
}
- $dir = '/' . $userId;
- /** @var Folder $folder */
- $folder = $this->rootFolder->get($dir);
-
return new Avatar($folder, $this->l, $user, $this->logger, $this->config);
}
}
diff --git a/lib/private/Files/AppData/AppData.php b/lib/private/Files/AppData/AppData.php
new file mode 100644
index 00000000000..270e834b8e5
--- /dev/null
+++ b/lib/private/Files/AppData/AppData.php
@@ -0,0 +1,131 @@
+<?php
+/**
+ * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Files\AppData;
+
+use OC\Files\SimpleFS\SimpleFolder;
+use OCP\Files\IAppData;
+use OCP\Files\IRootFolder;
+use OCP\Files\Folder;
+use OC\SystemConfig;
+use OCP\Files\Node;
+use OCP\Files\NotFoundException;
+use OCP\Files\NotPermittedException;
+
+class AppData implements IAppData {
+
+ /** @var IRootFolder */
+ private $rootFolder;
+
+ /** @var SystemConfig */
+ private $config;
+
+ /** @var string */
+ private $appId;
+
+ /** @var Folder */
+ private $folder;
+
+ /**
+ * AppData constructor.
+ *
+ * @param IRootFolder $rootFolder
+ * @param SystemConfig $systemConfig
+ * @param string $appId
+ */
+ public function __construct(IRootFolder $rootFolder,
+ SystemConfig $systemConfig,
+ $appId) {
+
+ $this->rootFolder = $rootFolder;
+ $this->config = $systemConfig;
+ $this->appId = $appId;
+ }
+
+ /**
+ * @return Folder
+ * @throws \RuntimeException
+ */
+ private function getAppDataFolder() {
+ if ($this->folder === null) {
+ $instanceId = $this->config->getValue('instanceid', null);
+ if ($instanceId === null) {
+ throw new \RuntimeException('no instance id!');
+ }
+
+ $name = 'appdata_' . $instanceId;
+
+ try {
+ $appDataFolder = $this->rootFolder->get($name);
+ } catch (NotFoundException $e) {
+ try {
+ $appDataFolder = $this->rootFolder->newFolder($name);
+ } catch (NotPermittedException $e) {
+ throw new \RuntimeException('Could not get appdata folder');
+ }
+ }
+
+ try {
+ $appDataFolder = $appDataFolder->get($this->appId);
+ } catch (NotFoundException $e) {
+ try {
+ $appDataFolder = $appDataFolder->newFolder($this->appId);
+ } catch (NotPermittedException $e) {
+ throw new \RuntimeException('Could not get appdata folder for ' . $this->appId);
+ }
+ }
+
+ $this->folder = $appDataFolder;
+ }
+
+ return $this->folder;
+ }
+
+ public function getFolder($name) {
+ $node = $this->getAppDataFolder()->get($name);
+
+ /** @var Folder $node */
+ return new SimpleFolder($node);
+ }
+
+ public function newFolder($name) {
+ $folder = $this->getAppDataFolder()->newFolder($name);
+
+ return new SimpleFolder($folder);
+ }
+
+ public function getDirectoryListing() {
+ $listing = $this->getAppDataFolder()->getDirectoryListing();
+
+ $fileListing = array_map(function(Node $folder) {
+ if ($folder instanceof Folder) {
+ return new SimpleFolder($folder);
+ }
+ return null;
+ }, $listing);
+
+ $fileListing = array_filter($fileListing);
+
+ return array_values($fileListing);
+ }
+}
diff --git a/lib/private/Files/AppData/Factory.php b/lib/private/Files/AppData/Factory.php
new file mode 100644
index 00000000000..85c75733796
--- /dev/null
+++ b/lib/private/Files/AppData/Factory.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OC\Files\AppData;
+
+use OC\SystemConfig;
+use OCP\Files\IRootFolder;
+
+class Factory {
+
+ /** @var IRootFolder */
+ private $rootFolder;
+
+ /** @var SystemConfig */
+ private $config;
+
+ public function __construct(IRootFolder $rootFolder,
+ SystemConfig $systemConfig) {
+
+ $this->rootFolder = $rootFolder;
+ $this->config = $systemConfig;
+ }
+
+ /**
+ * @param string $appId
+ * @return AppData
+ */
+ public function get($appId) {
+ return new AppData($this->rootFolder, $this->config, $appId);
+ }
+}
diff --git a/lib/private/Files/SimpleFS/SimpleFile.php b/lib/private/Files/SimpleFS/SimpleFile.php
new file mode 100644
index 00000000000..5eadfd98b60
--- /dev/null
+++ b/lib/private/Files/SimpleFS/SimpleFile.php
@@ -0,0 +1,115 @@
+<?php
+/**
+ * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OC\Files\SimpleFS;
+
+use OCP\Files\File;
+use OCP\Files\NotPermittedException;
+use OCP\Files\SimpleFS\ISimpleFile;
+
+class SimpleFile implements ISimpleFile {
+
+ /** @var File $file */
+ private $file;
+
+ /**
+ * File constructor.
+ *
+ * @param File $file
+ */
+ public function __construct(File $file) {
+ $this->file = $file;
+ }
+
+ /**
+ * Get the name
+ *
+ * @return string
+ */
+ public function getName() {
+ return $this->file->getName();
+ }
+
+ /**
+ * Get the size in bytes
+ *
+ * @return int
+ */
+ public function getSize() {
+ return $this->file->getSize();
+ }
+
+ /**
+ * Get the ETag
+ *
+ * @return string
+ */
+ public function getETag() {
+ return $this->file->getEtag();
+ }
+
+ /**
+ * Get the last modification time
+ *
+ * @return int
+ */
+ public function getMTime() {
+ return $this->file->getMTime();
+ }
+
+ /**
+ * Get the content
+ *
+ * @return string
+ */
+ public function getContent() {
+ return $this->file->getContent();
+ }
+
+ /**
+ * Overwrite the file
+ *
+ * @param string $data
+ * @throws NotPermittedException
+ */
+ public function putContent($data) {
+ $this->file->putContent($data);
+ }
+
+ /**
+ * Delete the file
+ *
+ * @throws NotPermittedException
+ */
+ public function delete() {
+ $this->file->delete();
+ }
+
+ /**
+ * Get the MimeType
+ *
+ * @return string
+ */
+ public function getMimeType() {
+ return $this->file->getMimeType();
+ }
+}
diff --git a/lib/private/Files/SimpleFS/SimpleFolder.php b/lib/private/Files/SimpleFS/SimpleFolder.php
new file mode 100644
index 00000000000..5b55fe0f157
--- /dev/null
+++ b/lib/private/Files/SimpleFS/SimpleFolder.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OC\Files\SimpleFS;
+
+use OCP\Files\File;
+use OCP\Files\Folder;
+use OCP\Files\Node;
+use OCP\Files\NotFoundException;
+use OCP\Files\SimpleFS\ISimpleFolder;
+
+class SimpleFolder implements ISimpleFolder {
+
+ /** @var Folder */
+ private $folder;
+
+ /**
+ * Folder constructor.
+ *
+ * @param Folder $folder
+ */
+ public function __construct(Folder $folder) {
+ $this->folder = $folder;
+ }
+
+ public function getName() {
+ return $this->folder->getName();
+ }
+
+ public function getDirectoryListing() {
+ $listing = $this->folder->getDirectoryListing();
+
+ $fileListing = array_map(function(Node $file) {
+ if ($file instanceof File) {
+ return new SimpleFile($file);
+ }
+ return null;
+ }, $listing);
+
+ $fileListing = array_filter($fileListing);
+
+ return array_values($fileListing);
+ }
+
+ public function delete() {
+ $this->folder->delete();
+ }
+
+ public function fileExists($name) {
+ return $this->folder->nodeExists($name);
+ }
+
+ public function getFile($name) {
+ $file = $this->folder->get($name);
+
+ if (!($file instanceof File)) {
+ throw new NotFoundException();
+ }
+
+ return new SimpleFile($file);
+ }
+
+ public function newFile($name) {
+ $file = $this->folder->newFile($name);
+
+ return new SimpleFile($file);
+ }
+}
diff --git a/lib/private/Repair.php b/lib/private/Repair.php
index bf441d03c35..2ba118b9c37 100644
--- a/lib/private/Repair.php
+++ b/lib/private/Repair.php
@@ -36,6 +36,7 @@ use OC\Repair\CleanTags;
use OC\Repair\Collation;
use OC\Repair\DropOldJobs;
use OC\Repair\MoveUpdaterStepFile;
+use OC\Repair\NC11\MoveAvatars;
use OC\Repair\OldGroupMembershipShares;
use OC\Repair\RemoveGetETagEntries;
use OC\Repair\RemoveOldShares;
@@ -149,6 +150,10 @@ class Repair implements IOutput{
\OC::$server->getGroupManager()
),
new MoveUpdaterStepFile(\OC::$server->getConfig()),
+ new MoveAvatars(
+ \OC::$server->getJobList(),
+ \OC::$server->getSystemConfig()
+ ),
];
}
diff --git a/lib/private/Repair/NC11/MoveAvatarBackgroundJob.php b/lib/private/Repair/NC11/MoveAvatarBackgroundJob.php
new file mode 100644
index 00000000000..993235146c9
--- /dev/null
+++ b/lib/private/Repair/NC11/MoveAvatarBackgroundJob.php
@@ -0,0 +1,104 @@
+<?php
+/**
+ * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OC\Repair\NC11;
+
+use OC\BackgroundJob\QueuedJob;
+use OCP\Files\File;
+use OCP\Files\Folder;
+use OCP\Files\IAppData;
+use OCP\Files\IRootFolder;
+use OCP\Files\NotFoundException;
+use OCP\ILogger;
+use OCP\IUser;
+use OCP\IUserManager;
+
+class MoveAvatarsBackgroundJob extends QueuedJob {
+
+ /** @var IUserManager */
+ private $userManager;
+
+ /** @var IRootFolder */
+ private $rootFolder;
+
+ /** @var IAppData */
+ private $appData;
+
+ /** @var ILogger */
+ private $logger;
+
+ /**
+ * MoveAvatars constructor.
+ */
+ public function __construct() {
+ $this->userManager = \OC::$server->getUserManager();
+ $this->rootFolder = \OC::$server->getRootFolder();
+ $this->logger = \OC::$server->getLogger();
+ $this->appData = \OC::$server->getAppDataDir('avatar');
+ }
+
+ public function run($arguments) {
+ $this->logger->info('Started migrating avatars to AppData folder');
+ $this->moveAvatars();
+ $this->logger->info('All avatars migrated to AppData folder');
+ }
+
+ private function moveAvatars() {
+ $counter = 0;
+ $this->userManager->callForAllUsers(function (IUser $user) use ($counter) {
+ if ($user->getLastLogin() !== 0) {
+ $uid = $user->getUID();
+
+ \OC\Files\Filesystem::initMountPoints($uid);
+ /** @var Folder $userFolder */
+ $userFolder = $this->rootFolder->get($uid);
+
+ try {
+ $userData = $this->appData->getFolder($uid);
+ } catch (NotFoundException $e) {
+ $userData = $this->appData->newFolder($uid);
+ }
+
+
+ $regex = '/^avatar\.([0-9]+\.)?(jpg|png)$/';
+ $avatars = $userFolder->getDirectoryListing();
+
+ foreach ($avatars as $avatar) {
+ /** @var File $avatar */
+ if (preg_match($regex, $avatar->getName())) {
+ /*
+ * This is not the most effective but it is the most abstract way
+ * to handle this. Avatars should be small anyways.
+ */
+ $newAvatar = $userData->newFile($avatar->getName());
+ $newAvatar->putContent($avatar->getContent());
+ $avatar->delete();
+ }
+ }
+ }
+ $counter++;
+ if ($counter % 100) {
+ $this->logger->info('{amount} avatars migrated', ['amount' => $counter]);
+ }
+ });
+ }
+}
diff --git a/lib/private/Repair/NC11/MoveAvatars.php b/lib/private/Repair/NC11/MoveAvatars.php
new file mode 100644
index 00000000000..44402b1be4f
--- /dev/null
+++ b/lib/private/Repair/NC11/MoveAvatars.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OC\Repair\NC11;
+
+use OC\SystemConfig;
+use OCP\BackgroundJob\IJobList;
+use OCP\Migration\IOutput;
+use OCP\Migration\IRepairStep;
+
+class MoveAvatars implements IRepairStep {
+
+ /** @var IJobList */
+ private $jobList;
+
+ /** @var SystemConfig */
+ private $systemConfig;
+
+ /**
+ * MoveAvatars constructor.
+ *
+ * @param IJobList $jobList
+ * @param SystemConfig $systemConfig
+ */
+ public function __construct(IJobList $jobList,
+ SystemConfig $systemConfig) {
+ $this->jobList = $jobList;
+ $this->systemConfig = $systemConfig;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName() {
+ return 'Add mover avatar background job';
+ }
+
+ public function run(IOutput $output) {
+ if ($this->systemConfig->getValue('enable_avatars', true) === false) {
+ $output->info('Avatars are disabled');
+ } else {
+ $this->jobList->add(MoveAvatarsBackgroundJob::class);
+ }
+ }
+}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 494387ab6ca..b49e94b554e 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -359,7 +359,7 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService('AvatarManager', function (Server $c) {
return new AvatarManager(
$c->getUserManager(),
- $c->getRootFolder(),
+ $c->getAppDataDir('avatar'),
$c->getL10N('lib'),
$c->getLogger(),
$c->getConfig()
@@ -742,6 +742,12 @@ class Server extends ServerContainer implements IServerContainer {
);
return $manager;
});
+ $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
+ return new \OC\Files\AppData\Factory(
+ $c->getRootFolder(),
+ $c->getSystemConfig()
+ );
+ });
}
/**
@@ -876,6 +882,7 @@ class Server extends ServerContainer implements IServerContainer {
* Returns an app-specific view in ownClouds data directory
*
* @return \OCP\Files\Folder
+ * @deprecated since 9.2.0 use IAppData
*/
public function getAppFolder() {
$dir = '/' . \OC_App::getCurrentApp();
@@ -1456,4 +1463,13 @@ class Server extends ServerContainer implements IServerContainer {
public function getSettingsManager() {
return $this->query('SettingsManager');
}
+
+ /**
+ * @return \OCP\Files\IAppData
+ */
+ public function getAppDataDir($app) {
+ /** @var \OC\Files\AppData\Factory $factory */
+ $factory = $this->query(\OC\Files\AppData\Factory::class);
+ return $factory->get($app);
+ }
}
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index cb52949779f..b8f3a93ba50 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -311,10 +311,20 @@ class OC_Util {
*
* @param String $userId
* @param \OCP\Files\Folder $userDirectory
+ * @throws \RuntimeException
*/
public static function copySkeleton($userId, \OCP\Files\Folder $userDirectory) {
- $skeletonDirectory = \OCP\Config::getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton');
+ $skeletonDirectory = \OC::$server->getConfig()->getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton');
+ $instanceId = \OC::$server->getConfig()->getSystemValue('instanceid', '');
+
+ if ($instanceId === null) {
+ throw new \RuntimeException('no instance id!');
+ }
+ $appdata = 'appdata_' . $instanceId;
+ if ($userId === $appdata) {
+ throw new \RuntimeException('username is reserved name: ' . $appdata);
+ }
if (!empty($skeletonDirectory)) {
\OCP\Util::writeLog(