feat: fix backups running twice in schedules

This commit is contained in:
naterfute
2025-06-11 10:52:59 -07:00
parent 6af57ae85e
commit 1fbfed33d5
2 changed files with 29 additions and 0 deletions

View File

@@ -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)) {

View File

@@ -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');
});
}
};