mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 00:34:44 +02:00
Catch 500 on backup page when you hit the backup rate limit (#1132)
* Catch backup throwable * phpstan * Update notification
This commit is contained in:
parent
c5230efad6
commit
adca50a372
@ -31,6 +31,7 @@ use Filament\Tables\Columns\IconColumn;
|
|||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
|
||||||
class ListBackups extends ListRecords
|
class ListBackups extends ListRecords
|
||||||
{
|
{
|
||||||
@ -166,18 +167,27 @@ class ListBackups extends ListRecords
|
|||||||
$action->setIsLocked((bool) $data['is_locked']);
|
$action->setIsLocked((bool) $data['is_locked']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$backup = $action->handle($server, $data['name']);
|
try {
|
||||||
|
$backup = $action->handle($server, $data['name']);
|
||||||
|
|
||||||
Activity::event('server:backup.start')
|
Activity::event('server:backup.start')
|
||||||
->subject($backup)
|
->subject($backup)
|
||||||
->property(['name' => $backup->name, 'locked' => (bool) $data['is_locked']])
|
->property(['name' => $backup->name, 'locked' => (bool) $data['is_locked']])
|
||||||
->log();
|
->log();
|
||||||
|
|
||||||
return Notification::make()
|
return Notification::make()
|
||||||
->title('Backup Created')
|
->title('Backup Created')
|
||||||
->body($backup->name . ' created.')
|
->body($backup->name . ' created.')
|
||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
|
} catch (HttpException $e) {
|
||||||
|
return Notification::make()
|
||||||
|
->danger()
|
||||||
|
->title('Backup Failed')
|
||||||
|
->body($e->getMessage() . ' Try again' . ($e->getHeaders()['Retry-After'] ? ' in ' . $e->getHeaders()['Retry-After'] . ' seconds.' : ''))
|
||||||
|
->send();
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ class InitiateBackupService
|
|||||||
if ($previous->count() >= $limit) {
|
if ($previous->count() >= $limit) {
|
||||||
$message = sprintf('Only %d backups may be generated within a %d second span of time.', $limit, $period);
|
$message = sprintf('Only %d backups may be generated within a %d second span of time.', $limit, $period);
|
||||||
|
|
||||||
throw new TooManyRequestsHttpException((int) now()->diffInSeconds($previous->last()->created_at->addSeconds($period)), $message);
|
throw new TooManyRequestsHttpException((int) now()->diffInSeconds($previous->last()->created_at->addSeconds((int) $period)), $message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user