Skip to content

Commit 9b99ec5

Browse files
committed
fix: reuse the mountpoint the wrapper was setup with
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent c3c9522 commit 9b99ec5

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

‎lib/AppInfo/Application.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use OCP\AppFramework\Bootstrap\IBootContext;
3131
use OCP\AppFramework\Bootstrap\IBootstrap;
3232
use OCP\AppFramework\Bootstrap\IRegistrationContext;
33+
use OCP\Files\Mount\IMountPoint;
3334
use OCP\Files\Storage\IStorage;
3435
use OCP\Util;
3536
use OCP\WorkflowEngine\Events\RegisterOperationsEvent;
@@ -53,13 +54,14 @@ public function addStorageWrapper() {
5354
* @param IStorage $storage
5455
* @return StorageWrapper|IStorage
5556
*/
56-
public function addStorageWrapperCallback($mountPoint, IStorage $storage) {
57+
public function addStorageWrapperCallback($mountPoint, IStorage $storage, IMountPoint $mount) {
5758
if (!OC::$CLI && $mountPoint !== '/') {
5859
/** @var Operation $operation */
5960
$operation = $this->getContainer()->get(Operation::class);
6061
return new StorageWrapper([
6162
'storage' => $storage,
6263
'mountPoint' => $mountPoint,
64+
'mount' => $mount,
6365
'operation' => $operation,
6466
]);
6567
}

‎lib/Operation.php‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,16 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch
290290
* @param array|ICacheEntry|null $cacheEntry
291291
*/
292292
private function getNode(IStorage $storage, string $path, $cacheEntry = null): ?Node {
293-
/** @var IMountPoint|false $mountPoint */
294-
$mountPoint = current($this->mountManager->findByStorageId($storage->getId()));
295-
if (!$mountPoint) {
296-
return null;
293+
if ($storage->instanceOfStorage(StorageWrapper::class)) {
294+
$mountPoint = $storage->getMount();
295+
} else {
296+
// fairly sure this branch is never taken, but not 100%
297+
298+
/** @var IMountPoint|false $mountPoint */
299+
$mountPoint = current($this->mountManager->findByStorageId($storage->getId()));
300+
if (!$mountPoint) {
301+
return null;
302+
}
297303
}
298304

299305
$fullPath = $mountPoint->getMountPoint() . $path;

‎lib/StorageWrapper.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use OC\Files\Storage\Wrapper\Wrapper;
2727
use OCP\Constants;
2828
use OCP\Files\ForbiddenException;
29+
use OCP\Files\Mount\IMountPoint;
2930
use OCP\Files\Storage\IStorage;
3031
use OCP\Files\Storage\IWriteStreamStorage;
3132

@@ -37,6 +38,7 @@ class StorageWrapper extends Wrapper implements IWriteStreamStorage {
3738
public $mountPoint;
3839
/** @var int */
3940
protected $mask;
41+
private IMountPoint $mount;
4042

4143
/**
4244
* @param array $parameters
@@ -45,6 +47,7 @@ public function __construct($parameters) {
4547
parent::__construct($parameters);
4648
$this->operation = $parameters['operation'];
4749
$this->mountPoint = $parameters['mountPoint'];
50+
$this->mount = $parameters['mount'];
4851

4952
$this->mask = Constants::PERMISSION_ALL;
5053
$this->mask &= ~Constants::PERMISSION_READ;
@@ -338,4 +341,8 @@ private function isPartFile($path) {
338341
$extension = pathinfo($path, PATHINFO_EXTENSION);
339342
return ($extension === 'part');
340343
}
344+
345+
public function getMount(): IMountPoint {
346+
return $this->mount;
347+
}
341348
}

0 commit comments

Comments
 (0)