diff --git a/lib/Trash/TrashBackend.php b/lib/Trash/TrashBackend.php index e878dec6c..1d5090367 100644 --- a/lib/Trash/TrashBackend.php +++ b/lib/Trash/TrashBackend.php @@ -239,9 +239,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); @@ -263,7 +261,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() ?? ''); // 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