File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Exceptions/Http/Connection Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 66use GuzzleHttp \Exception \GuzzleException ;
77use Pterodactyl \Exceptions \DisplayException ;
88
9+ /**
10+ * @method \GuzzleHttp\Exception\GuzzleException getPrevious()
11+ */
912class DaemonConnectionException extends DisplayException
1013{
1114 /**
Original file line number Diff line number Diff line change 22
33namespace Pterodactyl \Services \Backups ;
44
5+ use Illuminate \Http \Response ;
56use Pterodactyl \Models \Backup ;
7+ use GuzzleHttp \Exception \ClientException ;
68use Illuminate \Database \ConnectionInterface ;
79use Pterodactyl \Repositories \Eloquent \BackupRepository ;
810use Pterodactyl \Repositories \Wings \DaemonBackupRepository ;
11+ use Pterodactyl \Exceptions \Http \Connection \DaemonConnectionException ;
912
1013class DeleteBackupService
1114{
@@ -50,7 +53,16 @@ public function __construct(
5053 public function handle (Backup $ backup )
5154 {
5255 $ this ->connection ->transaction (function () use ($ backup ) {
53- $ this ->daemonBackupRepository ->setServer ($ backup ->server )->delete ($ backup );
56+ try {
57+ $ this ->daemonBackupRepository ->setServer ($ backup ->server )->delete ($ backup );
58+ } catch (DaemonConnectionException $ exception ) {
59+ $ previous = $ exception ->getPrevious ();
60+ // Don't fail the request if the Daemon responds with a 404, just assume the backup
61+ // doesn't actually exist and remove it's reference from the Panel as well.
62+ if (! $ previous instanceof ClientException || $ previous ->getResponse ()->getStatusCode () !== Response::HTTP_NOT_FOUND ) {
63+ throw $ exception ;
64+ }
65+ }
5466
5567 $ this ->repository ->delete ($ backup ->id );
5668 });
You can’t perform that action at this time.
0 commit comments