diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-06-21 16:10:48 +0200 |
---|---|---|
committer | Côme Chilliet (Rebase PR Action) <come-nc@users.noreply.github.com> | 2023-05-04 11:11:52 +0000 |
commit | 85770f3b9f12ef2ab054fca2327c2b6497abf2ca (patch) | |
tree | f46a1d90300668bbe4e9831b4b9ced1e0f78d511 /lib/private | |
parent | 527de8ac9d989baf30144e8f9bc0381226d4aee9 (diff) | |
download | nextcloud-server-85770f3b9f12ef2ab054fca2327c2b6497abf2ca.tar.gz nextcloud-server-85770f3b9f12ef2ab054fca2327c2b6497abf2ca.zip |
Make it easier to debug issue #32304
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/Node/LazyFolder.php | 7 | ||||
-rw-r--r-- | lib/private/Files/Node/LazyUserFolder.php | 19 |
2 files changed, 19 insertions, 7 deletions
diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php index cc1f64889a1..c843baabade 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -27,6 +27,7 @@ declare(strict_types=1); namespace OC\Files\Node; use OC\Files\Utils\PathHelper; +use OCP\Files\Folder; use OCP\Constants; /** @@ -37,8 +38,8 @@ use OCP\Constants; * * @package OC\Files\Node */ -class LazyFolder implements \OCP\Files\Folder { - /** @var \Closure */ +class LazyFolder implements Folder { + /** @var \Closure(): Folder */ private $folderClosure; /** @var LazyFolder | null */ @@ -49,7 +50,7 @@ class LazyFolder implements \OCP\Files\Folder { /** * LazyFolder constructor. * - * @param \Closure $folderClosure + * @param \Closure(): Folder $folderClosure */ public function __construct(\Closure $folderClosure, array $data = []) { $this->folderClosure = $folderClosure; diff --git a/lib/private/Files/Node/LazyUserFolder.php b/lib/private/Files/Node/LazyUserFolder.php index 81009532dbf..e9a15555c42 100644 --- a/lib/private/Files/Node/LazyUserFolder.php +++ b/lib/private/Files/Node/LazyUserFolder.php @@ -28,7 +28,10 @@ use OCP\Constants; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; use OCP\Files\NotFoundException; +use OCP\Files\Folder; +use OCP\Files\File; use OCP\IUser; +use Psr\Log\LoggerInterface; class LazyUserFolder extends LazyFolder { private IRootFolder $root; @@ -41,14 +44,22 @@ class LazyUserFolder extends LazyFolder { $this->user = $user; $this->mountManager = $mountManager; $this->path = '/' . $user->getUID() . '/files'; - parent::__construct(function () use ($user) { + parent::__construct(function () use ($user): Folder { try { - return $this->root->get('/' . $user->getUID() . '/files'); + $node = $this->root->get($this->path); + if ($node instanceof File) { + $e = new \RuntimeException(); + \OCP\Server::get(LoggerInterface::class)->error('User root storage is not a folder: ' . $this->path, [ + 'exception' => $e, + ]); + throw $e; + } + return $node; } catch (NotFoundException $e) { if (!$this->root->nodeExists('/' . $user->getUID())) { $this->root->newFolder('/' . $user->getUID()); } - return $this->root->newFolder('/' . $user->getUID() . '/files'); + return $this->root->newFolder($this->path); } }, [ 'path' => $this->path, @@ -59,7 +70,7 @@ class LazyUserFolder extends LazyFolder { } public function get($path) { - return $this->root->get('/' . $this->user->getUID() . '/files/' . ltrim($path, '/')); + return $this->root->get('/' . $this->user->getUID() . '/files' . ltrim($path, '/')); } /** |