diff --git a/lib/Trash/TrashBackend.php b/lib/Trash/TrashBackend.php index 00afd992e..4b5eb6299 100644 --- a/lib/Trash/TrashBackend.php +++ b/lib/Trash/TrashBackend.php @@ -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); @@ -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