Skip to content

Commit 74fd470

Browse files
committed
fix: Pass the mountpoint target user to storages without owner
Storages that do not have a dedicated owner (e.g. groupfolders, external storages) currently always assume the current session user as the owner. This leads to several issues when there is no user session but a node is obtained through a user folder. In order to have the correct user available we need to pass the user that is used to setup a mountpoint along to the storage layer as we generally assume that an owner is available for those. Signed-off-by: Julius Härtl <[email protected]>
1 parent 1389863 commit 74fd470

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

apps/files_external/lib/Config/ConfigAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
140140
}, $storages, $storageConfigs);
141141

142142
$mounts = array_map(function (StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
143+
$storage->setOwner($user->getUID());
143144
if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
144145
return new PersonalMount(
145146
$this->userStoragesService,

lib/private/Files/Storage/Common.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,19 @@ public function setAvailability($isAvailable) {
861861
$this->getStorageCache()->setAvailability($isAvailable);
862862
}
863863

864+
/**
865+
* Allow setting the storage owner
866+
*
867+
* This can be used for storages that do not have a dedicated owner, where we want to
868+
* pass the user that we setup the mountpoint for along to the storage layer
869+
*
870+
* @param string|null $user
871+
* @return void
872+
*/
873+
public function setOwner(?string $user): void {
874+
$this->owner = $user;
875+
}
876+
864877
/**
865878
* @return bool
866879
*/

lib/private/Files/Storage/Wrapper/Wrapper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,4 +674,8 @@ public function isWrapperOf(IStorage $storage) {
674674
}
675675
return false;
676676
}
677+
678+
public function setOwner(?string $user): void {
679+
$this->getWrapperStorage()->setOwner($user);
680+
}
677681
}

lib/public/Files/Storage/IStorage.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,16 @@ public function getUpdater();
460460
* @since 9.0.0
461461
*/
462462
public function getWatcher();
463+
464+
/**
465+
* Allow setting the storage owner
466+
*
467+
* This can be used for storages that do not have a dedicated owner, where we want to
468+
* pass the user that we setup the mountpoint for along to the storage layer
469+
*
470+
* @param string|null $user Owner user id
471+
* @return void
472+
* @since 29.0.0
473+
*/
474+
public function setOwner(?string $user): void;
463475
}

0 commit comments

Comments
 (0)