A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
fix: additional verify file subtasks cause parent to get stuck on processing
aminnausin6f9766d1c70a
diff --git a/app/Jobs/IndexFiles.php b/app/Jobs/IndexFiles.phpindex 2cfae453..3373b5c0 100755--- a/app/Jobs/IndexFiles.php+++ b/app/Jobs/IndexFiles.php@@ -47,7 +47,12 @@ class IndexFiles extends ManagedSubTask {try {$summary = $this->generateData();- $taskCountUpdates = count($this->embedChain) ? ['sub_tasks_complete' => '++', 'sub_tasks_total' => count($this->embedChain), 'sub_tasks_current' => count($this->embedChain), 'sub_tasks_pending' => count($this->embedChain)] : ['sub_tasks_complete' => '++'];+ $taskCountUpdates = count($this->embedChain) ? [+ 'sub_tasks_complete' => '++',+ 'sub_tasks_total' => count($this->embedChain),+ 'sub_tasks_current' => count($this->embedChain),+ 'sub_tasks_pending' => count($this->embedChain),+ ] : ['sub_tasks_complete' => '++'];$this->completeSubTask($taskService, $summary, $taskCountUpdates);diff --git a/app/Jobs/Utility/Subtitles/ScanSubtitles.php b/app/Jobs/Utility/Subtitles/ScanSubtitles.phpindex 85cc8cbd..62b96a1e 100644--- a/app/Jobs/Utility/Subtitles/ScanSubtitles.php+++ b/app/Jobs/Utility/Subtitles/ScanSubtitles.php@@ -24,7 +24,7 @@ class ScanSubtitles extends ManagedSubTask {/** @param SubtitleScanTarget[] $targets */public function __construct(int $taskId, array $targets, string $folderPath, bool $scanExternal) {- $subTask = SubTask::create(['task_id' => $taskId, 'status' => TaskStatus::PENDING, 'name' => 'Scan Subtitles for folder ' . $folderPath]);+ $subTask = SubTask::create(['task_id' => $taskId, 'status' => TaskStatus::PENDING, 'name' => 'Scan ' . count($targets) . ' Files for Subtitles']);$this->taskId = $taskId;$this->subTaskId = $subTask->id;@@ -35,12 +35,12 @@ class ScanSubtitles extends ManagedSubTask {}public function handle(TaskService $taskService, SubtitleScanner $subtitleScanner, SubtitleManager $manager): void {- if (! $this->beginSubTask($taskService)) {+ if (! $this->beginSubTask($taskService, 'Scanning for subtitle tracks in folder ' . $this->folderPath)) {return;}try {- $summary = $this->handleScanSubtitles($subtitleScanner, $manager);+ $summary = 'Scanning for subtitle tracks in folder ' . $this->folderPath . "\n" . $this->handleScanSubtitles($subtitleScanner, $manager);$this->completeSubTask($taskService, $summary);} catch (\Throwable $th) {$this->failSubTask($taskService, $th);@@ -69,12 +69,12 @@ class ScanSubtitles extends ManagedSubTask {* generate font information (as a json on metadata?)*/private function handleScanSubtitles(SubtitleScanner $subtitleScanner, SubtitleManager $manager): string {- $summary = 'Scanning for subtitle tracks on ' . count($this->targets) . ' targets';+ $summary = '';$batchTransactions = [];$scannedUuids = [];$metadataMap = Metadata::with('video.folder')- ->whereIn('uuid', array_column($this->targets, 'uuid'))+ ->whereIn('uuid', array_map(fn ($t) => $t->uuid, $this->targets))->get()->keyBy('uuid');diff --git a/app/Jobs/VerifyFiles.php b/app/Jobs/VerifyFiles.phpindex a588d14e..e6e46bfb 100755--- a/app/Jobs/VerifyFiles.php+++ b/app/Jobs/VerifyFiles.php@@ -58,10 +58,14 @@ class VerifyFiles extends ManagedSubTask {);}+ $additionalTaskChain = array_merge($this->embedChain, $this->subtitleScanChain);+ $additionalTaskCount = count($additionalTaskChain);+$taskCountUpdates = ['sub_tasks_complete' => '++',- 'sub_tasks_total' => count($this->embedChain) + count($this->subtitleScanChain),- 'sub_tasks_pending' => count($this->embedChain) + count($this->subtitleScanChain),+ 'sub_tasks_total' => $additionalTaskCount,+ 'sub_tasks_pending' => $additionalTaskCount,+ 'sub_tasks_current' => $additionalTaskCount,];if (count($this->subtitleScanChain)) {@@ -72,11 +76,8 @@ class VerifyFiles extends ManagedSubTask {// Starts other subtasks after updating current subtask and parent subtask states// The parent task "ends" after the batch empties so in theory, this should delay that anyways and does not need to run before the task update- foreach ($this->embedChain as $embedTask) {- $this->batch()->add($embedTask);- }- foreach ($this->subtitleScanChain as $scanTask) {- $this->batch()->add($scanTask);+ foreach ($additionalTaskChain as $additionalTask) {+ $this->batch()->add($additionalTask);}} catch (\Throwable $th) {$this->failSubTask($taskService, $th);diff --git a/app/Services/FileJobService.php b/app/Services/FileJobService.phpindex 10e173e2..b6bed359 100644--- a/app/Services/FileJobService.php+++ b/app/Services/FileJobService.php@@ -299,6 +299,15 @@ class FileJobService {// if task is not still processing, don't change what the current status is// otherwise base status on batch info+ // Track with total subtask count instead of current count+ // This should work because now I just add to the same batch rather than start new batches+ // This does not work+ // TODO: Make this setup work and get rid of current task count+ // if ($task->status !== TaskStatus::PROCESSING || $task->sub_tasks_total !== $batch->totalJobs) {+ // Log::warning('Early finalize batch return', ['Status' => $task->status, 'Total Task Count' => $task->sub_tasks_total, 'Batch Task Count' => $batch->totalJobs, 'Task' => $task]);+ // return;+ // }+// 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', ['Status' => $task->status, 'Current Task Count' => $task->sub_tasks_current, 'Batch Task Count' => $batch->totalJobs, 'Task' => $task]);