From c54e5c6eb52032cc09a180ea498526f74a24939b Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 12 Aug 2016 17:36:54 +0200 Subject: [PATCH] Store avatars outside of the home Inside a hidden ".avatars" folder. Doesn't require home FS setup --- lib/private/AvatarManager.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/private/AvatarManager.php b/lib/private/AvatarManager.php index 7eb91b4999e3..c3f719e288ae 100644 --- a/lib/private/AvatarManager.php +++ b/lib/private/AvatarManager.php @@ -84,15 +84,17 @@ public function getAvatar($userId) { throw new \Exception('user does not exist'); } - /* - * Fix for #22119 - * Basically we do not want to copy the skeleton folder - */ - \OC\Files\Filesystem::initMountPoints($userId); - $dir = '/' . $userId; - /** @var Folder $folder */ - $folder = $this->rootFolder->get($dir); + $avatarsFolder = $this->getFolder($this->rootFolder, '.avatars'); + $usersAvatarsFolder = $this->getFolder($avatarsFolder, $userId); - return new Avatar($folder, $this->l, $user, $this->logger); + return new Avatar($usersAvatarsFolder, $this->l, $user, $this->logger); + } + + private function getFolder(Folder $folder, $path) { + try { + return $folder->get($path); + } catch (NotFoundException $e) { + return $folder->newFolder($path); + } } }