Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/files_trashbin/lib/Trash/TrashItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ public function getStorage() {
return $this->fileInfo->getStorage();
}

#[\Override]
public function getStorageId(): int {
return $this->fileInfo->getStorageId();
}

#[\Override]
public function getId() {
return $this->fileInfo->getId();
Expand Down
1 change: 0 additions & 1 deletion lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,6 @@
'OC\\Files\\Cache\\Wrapper\\JailWatcher' => $baseDir . '/lib/private/Files/Cache/Wrapper/JailWatcher.php',
'OC\\Files\\Config\\CachedMountFileInfo' => $baseDir . '/lib/private/Files/Config/CachedMountFileInfo.php',
'OC\\Files\\Config\\CachedMountInfo' => $baseDir . '/lib/private/Files/Config/CachedMountInfo.php',
'OC\\Files\\Config\\LazyPathCachedMountInfo' => $baseDir . '/lib/private/Files/Config/LazyPathCachedMountInfo.php',
'OC\\Files\\Config\\LazyStorageMountInfo' => $baseDir . '/lib/private/Files/Config/LazyStorageMountInfo.php',
'OC\\Files\\Config\\MountProviderCollection' => $baseDir . '/lib/private/Files/Config/MountProviderCollection.php',
'OC\\Files\\Config\\UserMountCache' => $baseDir . '/lib/private/Files/Config/UserMountCache.php',
Expand Down
1 change: 0 additions & 1 deletion lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -1966,7 +1966,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Files\\Cache\\Wrapper\\JailWatcher' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/Wrapper/JailWatcher.php',
'OC\\Files\\Config\\CachedMountFileInfo' => __DIR__ . '/../../..' . '/lib/private/Files/Config/CachedMountFileInfo.php',
'OC\\Files\\Config\\CachedMountInfo' => __DIR__ . '/../../..' . '/lib/private/Files/Config/CachedMountInfo.php',
'OC\\Files\\Config\\LazyPathCachedMountInfo' => __DIR__ . '/../../..' . '/lib/private/Files/Config/LazyPathCachedMountInfo.php',
'OC\\Files\\Config\\LazyStorageMountInfo' => __DIR__ . '/../../..' . '/lib/private/Files/Config/LazyStorageMountInfo.php',
'OC\\Files\\Config\\MountProviderCollection' => __DIR__ . '/../../..' . '/lib/private/Files/Config/MountProviderCollection.php',
'OC\\Files\\Config\\UserMountCache' => __DIR__ . '/../../..' . '/lib/private/Files/Config/UserMountCache.php',
Expand Down
66 changes: 56 additions & 10 deletions lib/private/Files/Config/CachedMountFileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,67 @@

namespace OC\Files\Config;

use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Config\ICachedMountFileInfo;
use OCP\Files\Config\ICachedMountInfo;
use OCP\Files\Node;
use OCP\IUser;

class CachedMountFileInfo extends CachedMountInfo implements ICachedMountFileInfo {
class CachedMountFileInfo implements ICachedMountFileInfo {
public function __construct(
IUser $user,
int $storageId,
int $rootId,
string $mountPoint,
?int $mountId,
string $mountProvider,
string $rootInternalPath,
private string $internalPath,
private readonly ICachedMountInfo $mountInfo,
private readonly string $internalPath,
) {
parent::__construct($user, $storageId, $rootId, $mountPoint, $mountProvider, $mountId, $rootInternalPath);
}

#[\Override]
public function getUser(): IUser {
return $this->mountInfo->getUser();
}

#[\Override]
public function getStorageId(): int {
return $this->mountInfo->getStorageId();
}

#[\Override]
public function getRootId(): int {
return $this->mountInfo->getRootId();
}

#[\Override]
public function getMountPointNode(): ?Node {
return $this->mountInfo->getMountPointNode();
}

#[\Override]
public function getMountPoint(): string {
return $this->mountInfo->getMountPoint();
}

#[\Override]
public function getMountId(): ?int {
return $this->mountInfo->getMountId();
}

#[\Override]
public function getRootInternalPath(): string {
return $this->mountInfo->getRootInternalPath();
}

#[\Override]
public function getMountProvider(): string {
return $this->mountInfo->getMountProvider();
}

#[\Override]
public function getKey(): string {
return $this->mountInfo->getKey();
}

#[\Override]
public function getRootCacheEntry(): ICacheEntry {
return $this->mountInfo->getRootCacheEntry();
}

#[\Override]
Expand Down
12 changes: 8 additions & 4 deletions lib/private/Files/Config/CachedMountInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace OC\Files\Config;

use OC\Files\Filesystem;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Config\ICachedMountInfo;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
Expand All @@ -25,7 +25,7 @@ public function __construct(
protected string $mountPoint,
protected string $mountProvider,
protected ?int $mountId = null,
protected string $rootInternalPath = '',
protected ICacheEntry $rootCacheEntry,
) {
if (strlen($this->mountProvider) > 128) {
throw new \Exception("Mount provider $this->mountProvider name exceeds the limit of 128 characters");
Expand Down Expand Up @@ -60,7 +60,6 @@ public function getRootId(): int {
#[\Override]
public function getMountPointNode(): ?Node {
// TODO injection etc
Filesystem::initMountPoints($this->getUser()->getUID());
$userFolder = Server::get(IRootFolder::class)->getUserFolder($this->getUser()->getUID());
return $userFolder->getParent()->getFirstNodeById($this->getRootId());
}
Expand Down Expand Up @@ -91,7 +90,7 @@ public function getMountId(): ?int {
*/
#[\Override]
public function getRootInternalPath(): string {
return $this->rootInternalPath;
return $this->getRootCacheEntry()->getPath();
}

#[\Override]
Expand All @@ -103,4 +102,9 @@ public function getMountProvider(): string {
public function getKey(): string {
return $this->key;
}

#[\Override]
public function getRootCacheEntry(): ICacheEntry {
return $this->rootCacheEntry;
}
}
50 changes: 0 additions & 50 deletions lib/private/Files/Config/LazyPathCachedMountInfo.php

This file was deleted.

63 changes: 49 additions & 14 deletions lib/private/Files/Config/LazyStorageMountInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,55 @@

namespace OC\Files\Config;

use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Cache\IScanner;
use OCP\Files\Config\ICachedMountInfo;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Node;
use OCP\IUser;
use OCP\Server;

class LazyStorageMountInfo implements ICachedMountInfo {
private ?string $key = null;
private ?int $storageId = null;
private ?int $rootId = null;
private ?ICacheEntry $rootCacheEntry = null;

class LazyStorageMountInfo extends CachedMountInfo {
public function __construct(
IUser $user,
private IMountPoint $mount,
private readonly IUser $user,
private readonly IMountPoint $mount,
) {
parent::__construct($user, 0, 0, '', '');
$this->key = '';
}

/**
* @return int the numeric storage id of the mount
*/
#[\Override]
public function getStorageId(): int {
if (!$this->storageId) {
if ($this->storageId === null) {
$this->storageId = $this->mount->getNumericStorageId();
}
return parent::getStorageId();
return $this->storageId;
}

/**
* @return int the fileid of the root of the mount
*/
#[\Override]
public function getRootId(): int {
if (!$this->rootId) {
if ($this->rootId === null) {
$this->rootId = $this->mount->getStorageRootId();
}
return parent::getRootId();
return $this->rootId;
}

/**
* @return string the mount point of the mount for the user
*/
#[\Override]
public function getMountPoint(): string {
if (!$this->mountPoint) {
$this->mountPoint = $this->mount->getMountPoint();
}
return parent::getMountPoint();
return $this->mount->getMountPoint();
}

#[\Override]
Expand All @@ -75,9 +81,38 @@ public function getMountProvider(): string {

#[\Override]
public function getKey(): string {
if (!$this->key) {
if ($this->key === null) {
$this->key = $this->getRootId() . '::' . $this->getMountPoint();
}
return $this->key;
}

#[\Override]
public function getUser(): IUser {
return $this->user;
}

#[\Override]
public function getMountPointNode(): ?Node {
$userFolder = Server::get(IRootFolder::class)->getUserFolder($this->getUser()->getUID());
return $userFolder->getParent()->getFirstNodeById($this->getRootId());
}

#[\Override]
public function getRootCacheEntry(): ICacheEntry {
if ($this->rootCacheEntry === null) {
$storage = $this->mount->getStorage();
$entry = $storage->getCache()->get($this->getRootInternalPath());
if (!$entry) {
$storage->getScanner()->scan($this->getRootInternalPath(), IScanner::SCAN_SHALLOW);
$entry = $storage->getCache()->get($this->getRootInternalPath());
}
if (!$entry) {
throw new \RuntimeException('Root of mount not found in cache, even after scanning');
}
$this->rootCacheEntry = $entry;
}
return $this->rootCacheEntry;
}

}
Loading
Loading