Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TaskProcessing follow-up #46368

Merged
merged 16 commits into from
Jul 19, 2024
Merged

TaskProcessing follow-up #46368

merged 16 commits into from
Jul 19, 2024

Conversation

marcelklehr
Copy link
Member

@marcelklehr marcelklehr commented Jul 9, 2024

Summary

Pick up and solve lose ends in TaskProcessing

Checklist

* Use field 'file' for the file upload
*
* @param int $taskId The id of the task
* @return DataResponse<Http::STATUS_CREATED, array{fileId: int}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>

Check failure

Code scanning / Psalm

InvalidReturnType Error

The declared return type 'OCP\AppFramework\Http\DataResponse<201|404|500, array{fileId?: int, message?: string}, array<never, never>>' for OC\Core\Controller\TaskProcessingApiController::setFileContentsExApp is incorrect, got 'OCP\AppFramework\Http\DataResponse<201|400|404|500, array{fileId?: int, message?: string}, array<never, never>>'
$task = $this->taskProcessingManager->getTask($taskId);
$file = $this->request->getUploadedFile('file');
if (!isset($file['tmp_name'])) {
return new DataResponse(['message' => $this->l->t('Bad request')], Http::STATUS_BAD_REQUEST);

Check failure

Code scanning / Psalm

InvalidReturnStatement Error

The inferred type 'OCP\AppFramework\Http\DataResponse<400, array{message: string}, array<never, never>>' does not match the declared return type 'OCP\AppFramework\Http\DataResponse<201|404|500, array{fileId?: int, message?: string}, array<never, never>>' for OC\Core\Controller\TaskProcessingApiController::setFileContentsExApp
return new DataResponse(['message' => $this->l->t('Bad request')], Http::STATUS_BAD_REQUEST);
}
$data = file_get_contents($file['tmp_name']);
if (!$data) {

Check notice

Code scanning / Psalm

RiskyTruthyFalsyComparison Note

Operand of type false|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead.
@provokateurin provokateurin removed their request for review July 9, 2024 11:43
Copy link
Member

@julien-nc julien-nc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

core/Controller/TaskProcessingApiController.php Outdated Show resolved Hide resolved
$task = $this->taskProcessingManager->getTask($taskId);
$file = $this->request->getUploadedFile('file');
if (!isset($file['tmp_name'])) {
return new DataResponse(['message' => $this->l->t('Bad request')], Http::STATUS_BAD_REQUEST);

Check failure

Code scanning / Psalm

InvalidReturnStatement Error

The inferred type 'OCP\AppFramework\Http\DataResponse<400, array{message: string}, array<never, never>>' does not match the declared return type 'OCP\AppFramework\Http\DataResponse<201|404|500, array{fileId?: int, message?: string}, array<never, never>>' for OC\Core\Controller\TaskProcessingApiController::setFileContentsExApp
@@ -493,4 +529,15 @@
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}

private function setFileContentsInternal($data): int {

Check notice

Code scanning / Psalm

MissingParamType Note

Parameter $data has no provided type
@marcelklehr marcelklehr force-pushed the fix/task-processing branch 2 times, most recently from 58ad083 to 369681f Compare July 17, 2024 11:39
marcelklehr and others added 15 commits July 17, 2024 13:55
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Differentiate between output with file IDs and output with File data

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
…h ID instead of File object

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
…h ID instead of File object

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
… names

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
…tegers

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Copy link
Member

@bigcat88 bigcat88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marcelklehr marcelklehr merged commit a3c3eab into master Jul 19, 2024
166 checks passed
@marcelklehr marcelklehr deleted the fix/task-processing branch July 19, 2024 10:38
@blizzz blizzz mentioned this pull request Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants