Skip to content

Commit

Permalink
Merge pull request #46680 from nextcloud/backport/44294/stable28
Browse files Browse the repository at this point in the history
[stable28] fix: Pass the mountpoint target user to storages without owner
  • Loading branch information
AndyScherzinger authored Sep 3, 2024
2 parents c55ca78 + 49e9442 commit 208bbf3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/files_external/lib/Config/ConfigAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
}, $storages, $storageConfigs);

$mounts = array_map(function (StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
$storage->setOwner($user->getUID());
if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
return new PersonalMount(
$this->userStoragesService,
Expand Down
13 changes: 13 additions & 0 deletions lib/private/Files/Storage/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,19 @@ public function setAvailability($isAvailable) {
$this->getStorageCache()->setAvailability($isAvailable);
}

/**
* Allow setting the storage owner
*
* This can be used for storages that do not have a dedicated owner, where we want to
* pass the user that we setup the mountpoint for along to the storage layer
*
* @param string|null $user
* @return void
*/
public function setOwner(?string $user): void {
$this->owner = $user;
}

/**
* @return bool
*/
Expand Down
4 changes: 4 additions & 0 deletions lib/private/Files/Storage/Wrapper/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -674,4 +674,8 @@ public function isWrapperOf(IStorage $storage) {
}
return false;
}

public function setOwner(?string $user): void {
$this->getWrapperStorage()->setOwner($user);
}
}
12 changes: 12 additions & 0 deletions lib/public/Files/Storage/IStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,16 @@ public function getUpdater();
* @since 9.0.0
*/
public function getWatcher();

/**
* Allow setting the storage owner
*
* This can be used for storages that do not have a dedicated owner, where we want to
* pass the user that we setup the mountpoint for along to the storage layer
*
* @param string|null $user Owner user id
* @return void
* @since 28.0.10
*/
public function setOwner(?string $user): void;
}

0 comments on commit 208bbf3

Please sign in to comment.