Skip to content

Commit

Permalink
fixing some issue on null files
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialOwl committed Apr 23, 2021
1 parent 7e7b5f6 commit 53066d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions lib/Service/FilesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,15 @@ public function getChunksFromUser(string $userId, IIndexOptions $indexOptions):
$this->initFileSystems($userId);

/** @var Folder $files */
$files = $this->rootFolder->getUserFolder($userId)
->get($indexOptions->getOption('path', '/'));
try {
$files = $this->rootFolder->getUserFolder($userId)
->get($indexOptions->getOption('path', '/'));
} catch (Throwable $e) {
\OC::$server->getLogger()->log(2, 'Issue while retrieving rootFolder for ' . $userId);

return [];
}

if ($files instanceof Folder) {
return $this->getChunksFromDirectory($userId, $files);
} else {
Expand Down Expand Up @@ -377,6 +384,9 @@ private function generateFilesDocumentFromParent(string $userId, Folder $parent)
* @throws Exception
*/
private function generateFilesDocumentFromFile(string $viewerId, Node $file): FilesDocument {
if (is_null($file->getId())) {
throw new NotFoundException();
}

$this->isNodeIndexable($file);

Expand Down Expand Up @@ -467,6 +477,7 @@ public function getFileFromId(string $userId, int $fileId): Node {

$files = $this->rootFolder->getUserFolder($userId)
->getById($fileId);

if (sizeof($files) === 0) {
throw new FilesNotFoundException();
}
Expand Down Expand Up @@ -1181,11 +1192,15 @@ private function isNodeIndexable(Node $file) {
}
}

$parent = $file->getParent();
try {
$parent = $file->getParent();
} catch (NotFoundException $e) {
return;
}
$parentPath = $this->withoutBeginSlash($parent->getPath());
$path = substr($parent->getPath(), 8 + strpos($parentPath, '/'));
if (is_string($path)) {
$this->isNodeIndexable($file->getParent());
$this->isNodeIndexable($parent);
}
}

Expand Down

0 comments on commit 53066d1

Please sign in to comment.