Skip to content

Commit 652021e

Browse files
committed
fix: Task with single failed VerifyFiles subtask continues indefinitely
Fixes #209
1 parent 5f38ddd commit 652021e

7 files changed

Lines changed: 10 additions & 8 deletions

File tree

app/Jobs/GeneratePreviewImage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
}
3333

3434
public function handle(PreviewGeneratorService $previewGenerator, TaskService $taskService) {
35-
$this->beginTask($taskService);
35+
if (!$this->beginTask($taskService)) return;
3636

3737
try {
3838
$result = $previewGenerator->generateImage($this->data, $this->path, true);

app/Jobs/ManagedTask.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ abstract class ManagedTask implements ShouldQueue {
3535
* Sets subtask to processing
3636
* Sets subtask starting summary
3737
*/
38-
public function beginTask(TaskService $taskService, string $summary = ''): void {
38+
public function beginTask(TaskService $taskService, string $summary = ''): bool {
3939
if (! $this->taskId) {
4040
throw new LogicException('Task ID missing, cannot begin task');
4141
}
@@ -49,7 +49,7 @@ public function beginTask(TaskService $taskService, string $summary = ''): void
4949
$taskService->updateSubTask($this->subTaskId, ['status' => TaskStatus::CANCELLED, 'summary' => 'Parent Task was Cancelled']);
5050
$this->delete();
5151

52-
return;
52+
return false;
5353
}
5454

5555
$this->ensureTaskIsStarted($this->taskId);
@@ -59,6 +59,8 @@ public function beginTask(TaskService $taskService, string $summary = ''): void
5959
$taskService->updateTaskCounts($this->taskId, ['sub_tasks_pending' => '--']);
6060
$taskService->updateSubTask($this->subTaskId, ['status' => TaskStatus::PROCESSING, 'started_at' => $this->startedAt, 'summary' => $summary]);
6161
});
62+
63+
return true;
6264
}
6365

6466
public function completeTask(TaskService $taskService, string $summary = '', array $taskCountUpdates = ['sub_tasks_complete' => '++']): ?Task {

app/Jobs/SyncFiles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct($taskId) {
2828
* Execute the job.
2929
*/
3030
public function handle(TaskService $taskService): void {
31-
$this->beginTask($taskService);
31+
if (!$this->beginTask($taskService)) return;
3232

3333
try {
3434
$this->syncCache($taskService);

app/Jobs/Utility/Paths/CleanFolderPaths.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(public $folders, $taskId) {
2424
* Execute the job.
2525
*/
2626
public function handle(TaskService $taskService): void {
27-
$this->beginTask($taskService);
27+
if (!$this->beginTask($taskService)) return;
2828

2929
try {
3030
$summary = $this->cleanFolderPaths($taskService);

app/Jobs/Utility/Paths/CleanVideoPaths.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(public $videos, $taskId) {
2323
* Execute the job.
2424
*/
2525
public function handle(TaskService $taskService): void {
26-
$this->beginTask($taskService);
26+
if (!$this->beginTask($taskService)) return;
2727

2828
try {
2929
$summary = $this->cleanVideoPaths($taskService);

app/Jobs/VerifyFiles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(public $videos, int $taskId) {
5555
}
5656

5757
public function handle(TaskService $taskService, SubtitleScanner $subtitleScanner): void {
58-
$this->beginTask($taskService);
58+
if (!$this->beginTask($taskService)) return;
5959

6060
try {
6161
$summary = $this->verifyFiles($taskService, $subtitleScanner);

app/Jobs/VerifyFolders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(public $folders, $taskId) {
2727
* Execute the job.
2828
*/
2929
public function handle(TaskService $taskService): void {
30-
$this->beginTask($taskService);
30+
if (!$this->beginTask($taskService)) return;
3131

3232
try {
3333
$summary = $this->verifyFolders($taskService);

0 commit comments

Comments
 (0)