Skip to content

Commit 76709d7

Browse files
committed
feat(task-streaming): address review comments
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 0bd6072 commit 76709d7

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

lib/private/TaskProcessing/Manager.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,12 @@ public function setTaskProgress(int $id, float $progress): bool {
12681268
#[\Override]
12691269
public function setTaskIntermediateOutput(int $id, array $output): bool {
12701270
// TODO: Not sure if we should rather catch the exceptions of getTask here and fail silently
1271-
$task = $this->getTask($id);
1271+
try {
1272+
$task = $this->getTask($id);
1273+
} catch (NotFoundException|\OCP\TaskProcessing\Exception\Exception $e) {
1274+
$this->logger->debug('Couldn\'t find task, not sending intermediate output', ['exception' => $e, 'task_id' => $id]);
1275+
return false;
1276+
}
12721277
if ($task->getStatus() !== Task::STATUS_RUNNING) {
12731278
return false;
12741279
}

lib/public/TaskProcessing/IManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function setTaskResult(int $id, ?string $error, ?array $result, bool $isU
144144

145145
/**
146146
* Set the task intermediate output.
147-
* If notify_push is available, the output will be pushed to the user and the task won't be updated in the DB.
147+
* If notify_push is available, the output will be pushed to the user and the task will be updated in the DB every 2 seconds at most.
148148
*
149149
* @param int $id The id of the task
150150
* @param array $output The intermediate output

lib/public/TaskProcessing/SynchronousProviderOptions.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111
* @since 35.0.0
1212
*/
1313
class SynchronousProviderOptions {
14-
private \Closure $reportOutput;
14+
private \Closure $reportIntermediateOutput;
1515

1616
/**
1717
* @param bool $includeWatermarks Whether to include the watermark in the media output files or not
1818
* @param bool $preferStreaming Whether to prefer streaming the output or not
19-
* @param null|callable $reportOutput Callback for the provider to report the intermediate output (streaming)
19+
* @param null|callable $reportIntermediateOutput Callback for the provider to report the intermediate output (streaming)
2020
* @return void
2121
* @since 35.0.0
2222
*/
2323
public function __construct(
2424
private readonly bool $includeWatermarks = false,
2525
private readonly bool $preferStreaming = true,
26-
?callable $reportOutput = null,
26+
?callable $reportIntermediateOutput = null,
2727
) {
28-
$this->reportOutput = $reportOutput !== null
29-
? \Closure::fromCallable($reportOutput)
28+
$this->reportIntermediateOutput = $reportIntermediateOutput !== null
29+
? \Closure::fromCallable($reportIntermediateOutput)
3030
: static function (array $output): bool {
3131
return true;
3232
};
@@ -55,7 +55,7 @@ public function getPreferStreaming(): bool {
5555
* @return callable Callback for the provider to report the intermediate output (streaming)
5656
* @since 35.0.0
5757
*/
58-
public function getReportOutput(): callable {
59-
return $this->reportOutput;
58+
public function getReportIntermediateOutput(): callable {
59+
return $this->reportIntermediateOutput;
6060
}
6161
}

0 commit comments

Comments
 (0)