From 75bb68ebdf3280c985efc7ded4fd4e0c2118fbb6 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Sat, 13 Jan 2018 10:08:52 -0100 Subject: index cleaning Signed-off-by: Maxence Lange --- lib/Model/Index.php | 17 +++++++++++++++-- lib/Model/ProviderIndexes.php | 18 ------------------ 2 files changed, 15 insertions(+), 20 deletions(-) (limited to 'lib/Model') diff --git a/lib/Model/Index.php b/lib/Model/Index.php index f25da7e..9924871 100644 --- a/lib/Model/Index.php +++ b/lib/Model/Index.php @@ -30,11 +30,14 @@ class Index implements \JsonSerializable { const INDEX_OK = 1; const INDEX_IGNORE = 2; + const INDEX_META = 4; const INDEX_CONTENT = 8; const INDEX_FULL = 12; const INDEX_REMOVE = 16; - const INDEX_FAILED = 32; + + const INDEX_DONE = 32; + const INDEX_FAILED = 64; const ERROR_FAILED = 1; const ERROR_FAILED2 = 2; @@ -126,12 +129,22 @@ class Index implements \JsonSerializable { /** * @param int $status * - * @return int + * @return bool */ public function isStatus($status) { return ((int)$status & $this->getStatus()); } + /** + * @param int $status + */ + public function unsetStatus($status) { + if (!$this->isStatus($status)) { + return; + } + + $this->status -= $status; + } /** * @param int $err diff --git a/lib/Model/ProviderIndexes.php b/lib/Model/ProviderIndexes.php index 510666c..2915181 100644 --- a/lib/Model/ProviderIndexes.php +++ b/lib/Model/ProviderIndexes.php @@ -62,22 +62,4 @@ class ProviderIndexes { } - public function isDocumentIndexUpToDate(IndexDocument $document) { - $index = $this->getIndex($document->getId()); - if ($index === null) { - $index = new Index($document->getProviderId(), $document->getId()); - $index->setStatus(Index::INDEX_FULL); - $index->setLastIndex(); - } - - $document->setIndex($index); - - if ($index->getStatus() !== Index::INDEX_OK) { - return false; - } - - return ($index->getLastIndex() >= $document->getModifiedTime()); - } - - } \ No newline at end of file -- cgit v1.2.3