Skip to content

Commit 3bf19f7

Browse files
authored
Merge pull request #32961 from nextcloud/more-debug-lazyuserfolder
Make it easier to debug issue #32304
2 parents 2f467d9 + 1cc1866 commit 3bf19f7

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

lib/private/Files/Node/LazyFolder.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
namespace OC\Files\Node;
2828

2929
use OC\Files\Utils\PathHelper;
30+
use OCP\Files\Folder;
3031
use OCP\Constants;
3132

3233
/**
@@ -37,8 +38,8 @@
3738
*
3839
* @package OC\Files\Node
3940
*/
40-
class LazyFolder implements \OCP\Files\Folder {
41-
/** @var \Closure */
41+
class LazyFolder implements Folder {
42+
/** @var \Closure(): Folder */
4243
private $folderClosure;
4344

4445
/** @var LazyFolder | null */
@@ -49,7 +50,7 @@ class LazyFolder implements \OCP\Files\Folder {
4950
/**
5051
* LazyFolder constructor.
5152
*
52-
* @param \Closure $folderClosure
53+
* @param \Closure(): Folder $folderClosure
5354
*/
5455
public function __construct(\Closure $folderClosure, array $data = []) {
5556
$this->folderClosure = $folderClosure;

lib/private/Files/Node/LazyUserFolder.php

+14-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
use OCP\Files\IRootFolder;
2929
use OCP\Files\Mount\IMountManager;
3030
use OCP\Files\NotFoundException;
31+
use OCP\Files\Folder;
32+
use OCP\Files\File;
3133
use OCP\IUser;
34+
use Psr\Log\LoggerInterface;
3235

3336
class LazyUserFolder extends LazyFolder {
3437
private IRootFolder $root;
@@ -41,14 +44,22 @@ public function __construct(IRootFolder $rootFolder, IUser $user, IMountManager
4144
$this->user = $user;
4245
$this->mountManager = $mountManager;
4346
$this->path = '/' . $user->getUID() . '/files';
44-
parent::__construct(function () use ($user) {
47+
parent::__construct(function () use ($user): Folder {
4548
try {
46-
return $this->root->get('/' . $user->getUID() . '/files');
49+
$node = $this->root->get($this->path);
50+
if ($node instanceof File) {
51+
$e = new \RuntimeException();
52+
\OCP\Server::get(LoggerInterface::class)->error('User root storage is not a folder: ' . $this->path, [
53+
'exception' => $e,
54+
]);
55+
throw $e;
56+
}
57+
return $node;
4758
} catch (NotFoundException $e) {
4859
if (!$this->root->nodeExists('/' . $user->getUID())) {
4960
$this->root->newFolder('/' . $user->getUID());
5061
}
51-
return $this->root->newFolder('/' . $user->getUID() . '/files');
62+
return $this->root->newFolder($this->path);
5263
}
5364
}, [
5465
'path' => $this->path,

0 commit comments

Comments
 (0)