mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 14:23:17 -04:00
Merge pull request #32961 from nextcloud/more-debug-lazyuserfolder
Make it easier to debug issue #32304
This commit is contained in:
commit
3bf19f76e6
2 changed files with 18 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue