Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/Controller/QueueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ public function getFileContents(IRootFolder $rootFolder, int $fileId, string $us
try {
$file = $rootFolder->getUserFolder($userId)->getFirstNodeById($fileId);
if (!$file || !$file instanceof \OCP\Files\File) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
return new DataResponse(['error' => 'Node is not a file or could not be found.'], Http::STATUS_NOT_FOUND);
}

$stream = $file->fopen('r');
if (!$stream) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
return new DataResponse(['error' => 'File could not be opened for reading.'], Http::STATUS_UNPROCESSABLE_ENTITY);
}

return new Http\StreamResponse($stream);
} catch (\Throwable $e) {
// Avoid leaking filesystem details; keep behavior consistent with other failure paths.
return new DataResponse([], Http::STATUS_NOT_FOUND);
$this->logger->error('Unknown error trying to read a file for indexing: ' . $e->getMessage(), ['exception' => $e]);
return new DataResponse(['error' => 'Unknown error occurred.'], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}

Expand Down
Loading