repository = $repository; $this->daemonBackupRepository = $daemonBackupRepository; $this->connection = $connection; } /** * Deletes a backup from the system. * * @param \Pterodactyl\Models\Backup $backup * @throws \Throwable */ public function handle(Backup $backup) { $this->connection->transaction(function () use ($backup) { try { $this->daemonBackupRepository->setServer($backup->server)->delete($backup); } catch (DaemonConnectionException $exception) { $previous = $exception->getPrevious(); // Don't fail the request if the Daemon responds with a 404, just assume the backup // doesn't actually exist and remove it's reference from the Panel as well. if (! $previous instanceof ClientException || $previous->getResponse()->getStatusCode() !== Response::HTTP_NOT_FOUND) { throw $exception; } } $this->repository->delete($backup->id); }); } }