Преглед на файлове

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 <jus@bitgrid.net>
pull/44294/head
Julius Härtl преди 2 месеца
родител
ревизия
4910e7e231
No account linked to committer's email address

+ 1
- 0
apps/files_external/lib/Config/ConfigAdapter.php Целия файл

@@ -140,6 +140,7 @@ class ConfigAdapter implements IMountProvider {
}, $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,

+ 13
- 0
lib/private/Files/Storage/Common.php Целия файл

@@ -867,6 +867,19 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
$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
*/

+ 4
- 0
lib/private/Files/Storage/Wrapper/Wrapper.php Целия файл

@@ -674,4 +674,8 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea
}
return false;
}

public function setOwner(?string $user): void {
$this->getWrapperStorage()->setOwner($user);
}
}

+ 12
- 0
lib/public/Files/Storage/IStorage.php Целия файл

@@ -460,4 +460,16 @@ interface IStorage {
* @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 29.0.0
*/
public function setOwner(?string $user): void;
}

Loading…
Отказ
Запис