Skip to content

A self-hosted media server and file management system

fix: scan files has incorrect task counts due to missed field sub_tasks_current

aminnausin82ef954c33aa
diff --git a/app/Jobs/IndexFiles.php b/app/Jobs/IndexFiles.php
index a9badc84..24fca038 100755
--- a/app/Jobs/IndexFiles.php
+++ b/app/Jobs/IndexFiles.php
@@ -18,8 +18,8 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
-use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\File;
+use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Ramsey\Uuid\Uuid;
@@ -71,18 +71,18 @@ class IndexFiles implements ShouldBeUnique, ShouldQueue {
$summary = $this->generateData();
$endedAt = now();
$duration = (int) $this->startedAt->diffInSeconds($endedAt);
+ $taskUpdateData = ['sub_tasks_complete' => '++'];
if (count($this->embedChain)) {
- $this->taskService->updateTaskCounts($this->taskId, ['sub_tasks_complete' => '++', 'sub_tasks_total' => count($this->embedChain), 'sub_tasks_pending' => count($this->embedChain)]);
+ $taskUpdateData = [...$taskUpdateData, 'sub_tasks_total' => count($this->embedChain), 'sub_tasks_current' => count($this->embedChain), 'sub_tasks_pending' => count($this->embedChain)];
foreach ($this->embedChain as $embedTask) {
- Bus::dispatch($embedTask);
+ $this->batch()->add($embedTask);
}
// $controller = new JobController($this->taskService);
// $controller->embedUIDs($this->taskId, "Embed UIDs for task $this->taskId via Index Files", $this->embedChain);
- } else {
- $this->taskService->updateTaskCounts($this->taskId, ['sub_tasks_complete' => '++'], false);
}
+ $this->taskService->updateTaskCounts($this->taskId, $taskUpdateData, count($taskUpdateData) !== 1);
$this->taskService->updateSubTask($this->subTaskId, [
'status' => TaskStatus::COMPLETED,
'summary' => $summary,
@@ -490,6 +490,7 @@ class IndexFiles implements ShouldBeUnique, ShouldQueue {
$embeddingUuid = false;
if (! $uuid || ! Uuid::isValid($uuid)) {
$uuid = Str::uuid()->toString();
+ // $this->batch()->add(new EmbedUidInMetadata($absolutePath, $uuid, $this->taskId, $currentID));
$this->embedChain[] = new EmbedUidInMetadata($absolutePath, $uuid, $this->taskId, $currentID);
$embeddingUuid = true;
// $this->embedChain[] = ["path" => $absolutePath, "uid" => $uuid];
diff --git a/app/Services/FileJobService.php b/app/Services/FileJobService.php
index 7c3042db..daac5b65 100644
--- a/app/Services/FileJobService.php
+++ b/app/Services/FileJobService.php
@@ -304,7 +304,7 @@ class FileJobService {
// if not processing or numbers dont match, task was ended elsewhere or has not started ?
if ($task->status !== TaskStatus::PROCESSING || $task->sub_tasks_current !== $batch->totalJobs) {
- Log::warning('Early finalize batch return', [$task->sub_tasks_current, $batch->totalJobs]);
+ Log::warning('Early finalize batch return', ['Status' => $task->status, 'Current Task Count' => $task->sub_tasks_current, 'Batch Task Count' => $batch->totalJobs, 'Task' => $task]);
return;
// Might be incorrect