Skip to content

Commit

Permalink
Merge pull request #3627 from nextcloud/backport/3604/stable30
Browse files Browse the repository at this point in the history
  • Loading branch information
provokateurin authored Feb 19, 2025
2 parents 0a7a1c7 + 435a410 commit 453172e
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 @@ -236,9 +236,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 @@ -255,7 +253,7 @@ public function moveToTrash(IStorage $storage, string $internalPath): bool {
$result = $trashStorage->moveFromStorage($storage, $internalPath, $targetInternalPath);
}
if ($result) {
$this->trashManager->addTrashItem($folderId, $name, $time, $internalPath, $fileEntry->getId(), $user->getUID());
$this->trashManager->addTrashItem($folderId, $name, $time, $internalPath, $fileEntry->getId(), $user?->getUID() ?? '');

// 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 453172e

Please sign in to comment.