made difftaskservice progressCallback optional

This commit is contained in:
Jonathan Treffler 2023-09-04 16:05:49 +02:00 committed by root
parent a0b6a25508
commit fb1290e671

View file

@ -53,7 +53,7 @@ class DiffTaskService {
}
}
function create(int $groupfolderId, string $snapshotId, string $userId, $progressCallback): DiffTask {
function create(int $groupfolderId, string $snapshotId, string $userId, Callable $progressCallback = null): DiffTask {
$snapshotPath = $this->pathManager->getGroupFolderSnapshotDirectory($groupfolderId, $snapshotId);
$groupfolderPath = $this->pathManager->getGroupFolderDirectory($groupfolderId);
@ -83,7 +83,7 @@ class DiffTaskService {
$newResult = $this->diffTaskResultMapper->insert($newResult);
},
function($numDoneFiles) use ($progressCallback, &$numFiles) {
if(($numFiles != 0) && ($numFiles != $numDoneFiles)) {
if(isset($progressCallback) && ($numFiles != 0) && ($numFiles != $numDoneFiles)) {
($progressCallback)([
"overallFiles" => $numFiles,
"doneFiles" => $numDoneFiles,
@ -98,14 +98,15 @@ class DiffTaskService {
$diffTask->diff();
if(isset($progressCallback)) {
($progressCallback)([
"overallFiles" => $numFiles,
"doneFiles" => $numFiles,
"progress" => 1.0,
"progressPercent" => "100.00%",
// TODO: include task results in object
"result" => $task,
]);
}
return $task;
}