Skip to content

Commit

Permalink
fix(trash): Fix deleting items from public share with write access
Browse files Browse the repository at this point in the history
When no user in session, default to owner.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Feb 11, 2025
1 parent df8560f commit b293363
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/Trash/TrashBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,7 @@ public function moveToTrash(IStorage $storage, string $internalPath): bool {
$fileEntry = $storage->getCache()->get($internalPath);
$folderId = $storage->getFolderId();
$user = $this->userSession->getUser();
if (!$user) {
throw new \Exception('file moved to trash with no user in context');
}

// ensure the folder exists
$this->getTrashFolder($folderId);

Expand All @@ -261,7 +259,7 @@ public function moveToTrash(IStorage $storage, string $internalPath): bool {
$originalLocation = $storage->getWrapperStorage()->getUnjailedPath($originalLocation);
}

$this->trashManager->addTrashItem($folderId, $name, $time, $originalLocation, $fileEntry->getId(), $user->getUID());
$this->trashManager->addTrashItem($folderId, $name, $time, $originalLocation, $fileEntry->getId(), $user?->getUID() ?? $owner);

// some storage backends (object/encryption) can either already move the cache item or cause the target to be scanned
// so we only conditionally do the cache move here
Expand Down

0 comments on commit b293363

Please sign in to comment.