Skip to content

Commit

Permalink
Merge pull request nextcloud#73 from nextcloud/feature/noid/new-events
Browse files Browse the repository at this point in the history
onGetConfig + onIndexComparing
  • Loading branch information
ArtificialOwl authored Jul 13, 2019
2 parents 5901210 + 9a43a57 commit 93c00c8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
13 changes: 11 additions & 2 deletions lib/Provider/FilesProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use OCA\Files_FullTextSearch\Exceptions\FileIsNotIndexableException;
use OCA\Files_FullTextSearch\Model\FilesDocument;
use OCA\Files_FullTextSearch\Service\ConfigService;
use OCA\Files_FullTextSearch\Service\ExtensionService;
use OCA\Files_FullTextSearch\Service\FilesService;
use OCA\Files_FullTextSearch\Service\MiscService;
use OCA\Files_FullTextSearch\Service\SearchService;
Expand Down Expand Up @@ -77,6 +78,9 @@ class FilesProvider implements IFullTextSearchProvider {
/** @var SearchService */
private $searchService;

/** @var ExtensionService */
private $extensionService;

/** @var MiscService */
private $miscService;

Expand All @@ -89,12 +93,13 @@ class FilesProvider implements IFullTextSearchProvider {

public function __construct(
IL10N $l10n, ConfigService $configService, FilesService $filesService,
SearchService $searchService, MiscService $miscService
SearchService $searchService, ExtensionService $extensionService, MiscService $miscService
) {
$this->l10n = $l10n;
$this->configService = $configService;
$this->filesService = $filesService;
$this->searchService = $searchService;
$this->extensionService = $extensionService;
$this->miscService = $miscService;
}

Expand All @@ -119,7 +124,10 @@ public function getName(): string {
* @return array
*/
public function getConfiguration(): array {
return $this->configService->getConfig();
$config = $this->configService->getConfig();
$this->extensionService->getConfig($config);

return $config;
}


Expand Down Expand Up @@ -228,6 +236,7 @@ public function loadProvider() {
*/
public function generateChunks(string $userId): array {
$chunks = $this->filesService->getChunksFromUser($userId, $this->indexOptions);

return $chunks;
}

Expand Down
24 changes: 24 additions & 0 deletions lib/Service/ExtensionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@


use OCA\Files_FullTextSearch\Model\FilesDocument;
use OCP\FullTextSearch\Model\IIndex;
use OCP\FullTextSearch\Model\IIndexDocument;
use OCP\FullTextSearch\Model\ISearchRequest;
use OCP\Files\Node;
use OCP\FullTextSearch\Model\ISearchResult;
Expand Down Expand Up @@ -73,6 +75,17 @@ public function __construct(
}


/**
* @param array $config
*/
public function getConfig(array &$config) {
$this->dispatch(
'\OCA\Files_FullTextSearch::onGetConfig',
['config' => &$config]
);
}


/**
* @param FilesDocument $document
* @param Node $file
Expand Down Expand Up @@ -107,6 +120,17 @@ public function searchResult(ISearchResult &$result) {
}


/**
* @param IIndexDocument $document
*/
public function indexComparing(IIndexDocument &$document) {
$this->dispatch(
'\OCA\Files_FullTextSearch::onIndexComparing',
['document' => &$document]
);
}


/**
* @param string $context
* @param array $arguments
Expand Down
9 changes: 5 additions & 4 deletions lib/Service/FilesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ public function getFileFromPath(string $userId, string $path): Node {
* @throws EmptyUserException
*/
public function getFileFromId(string $userId, int $fileId): Node {

if ($userId === '') {
throw new EmptyUserException();
}
Expand Down Expand Up @@ -466,8 +465,8 @@ public function getFileFromIndex(IIndex $index): Node {
* @param int $fileId
* @param string $viewerId
*
* @throws Exception
* @return string
* @throws Exception
*/
private function getPathFromViewerId(int $fileId, string $viewerId): string {

Expand Down Expand Up @@ -554,8 +553,11 @@ private function generateDocumentFromIndex(IIndex $index): FilesDocument {
* @return bool
*/
public function isDocumentUpToDate(IIndexDocument $document): bool {
$this->extensionService->indexComparing($document);

$index = $document->getIndex();


if (!$this->configService->compareIndexOptions($index)) {
$index->setStatus(IIndex::INDEX_CONTENT);
$document->setIndex($index);
Expand Down Expand Up @@ -663,8 +665,7 @@ private function updateContentFromFile(FilesDocument $document, Node $file) {

if ((!$document->getIndex()
->isStatus(IIndex::INDEX_CONTENT)
&&
!$document->getIndex()
&& !$document->getIndex()
->isStatus(IIndex::INDEX_META)
)
|| $file->getType() !== FileInfo::TYPE_FILE) {
Expand Down

0 comments on commit 93c00c8

Please sign in to comment.