mirror of
https://github.com/pyrohost/pyrodactyl.git
synced 2026-04-06 04:01:58 +02:00
fix: hackily handle locked backups during server deletion
This commit is contained in:
@@ -10,6 +10,7 @@ use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
||||
use Pterodactyl\Services\Databases\DatabaseManagementService;
|
||||
use Pterodactyl\Services\Backups\DeleteBackupService;
|
||||
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
use Pterodactyl\Exceptions\Service\Backup\BackupLockedException;
|
||||
|
||||
class ServerDeletionService
|
||||
{
|
||||
@@ -63,6 +64,28 @@ class ServerDeletionService
|
||||
foreach ($server->backups as $backup) {
|
||||
try {
|
||||
$this->deleteBackupService->handle($backup);
|
||||
} catch (BackupLockedException $exception) {
|
||||
// If the backup is locked, unlock it and try again since we're deleting the entire server
|
||||
$backup->update(['is_locked' => false]);
|
||||
|
||||
try {
|
||||
$this->deleteBackupService->handle($backup);
|
||||
} catch (\Exception $retryException) {
|
||||
if (!$this->force) {
|
||||
throw $retryException;
|
||||
}
|
||||
|
||||
// If we still can't delete the backup from storage, at least remove the database record
|
||||
// to prevent orphaned backup entries
|
||||
$backup->delete();
|
||||
|
||||
Log::warning('Failed to delete unlocked backup during server deletion', [
|
||||
'backup_id' => $backup->id,
|
||||
'backup_uuid' => $backup->uuid,
|
||||
'server_id' => $server->id,
|
||||
'exception' => $retryException->getMessage(),
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
if (!$this->force) {
|
||||
throw $exception;
|
||||
|
||||
Reference in New Issue
Block a user