mirror of
https://github.com/pyrohost/pyrodactyl.git
synced 2026-04-06 04:01:58 +02:00
feat: fix backups running twice in schedules
This commit is contained in:
@@ -68,12 +68,20 @@ class RunTaskJob extends Job implements ShouldQueue
|
||||
$commandRepository->setServer($server)->send($this->task->payload);
|
||||
break;
|
||||
case Task::ACTION_BACKUP:
|
||||
// Mark the task as running before initiating the backup to prevent duplicate runs
|
||||
$this->task->update(['is_processing' => true]);
|
||||
$backupService->setIgnoredFiles(explode(PHP_EOL, $this->task->payload))->handle($server, null, true);
|
||||
$this->task->update(['is_processing' => false]);
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid task action provided: ' . $this->task->action);
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
// Reset the processing flag if there was an error
|
||||
if ($this->task->action === Task::ACTION_BACKUP) {
|
||||
$this->task->update(['is_processing' => false]);
|
||||
}
|
||||
|
||||
// If this isn't a DaemonConnectionException on a task that allows for failures
|
||||
// throw the exception back up the chain so that the task is stopped.
|
||||
if (!($this->task->continue_on_failure && $exception instanceof DaemonConnectionException)) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tasks', function (Blueprint $table) {
|
||||
$table->boolean('is_processing')->default(false)->after('is_queued');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('tasks', function (Blueprint $table) {
|
||||
$table->dropColumn('is_processing');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user