diff options
author | Phie <phie@phie.ovh> | 2019-09-30 14:56:22 +0300 |
---|---|---|
committer | Phie <phie@phie.ovh> | 2019-09-30 14:56:22 +0300 |
commit | 9a3fc6dc69819e39d01214e5a4a011b6c9c6dbc9 (patch) | |
tree | b77d8a2928ddece01e5d8fd112e528fab286cb7e /lib | |
parent | 526c6b612fb8f7a8189910bc6788915012fa530c (diff) |
merging db before getting them + fix undefined keyword
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/Controller/NoteController.php | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Controller/NoteController.php b/lib/Controller/NoteController.php index 40f4db9..ca354ac 100755 --- a/lib/Controller/NoteController.php +++ b/lib/Controller/NoteController.php @@ -107,13 +107,14 @@ * @NoAdminRequired */ public function getRecent() { - + if(!$this->CarnetFolder->nodeExists("quickdoc/recentdb/recentnc")) + $this->mergeRecentDB(); $recents = json_decode($this->getRecentFile()->getContent(),true); $paths = array(); if($recents['data'] == null) $recents['data'] = array(); - if($recents['metadata'] != null){ //fix an old bug + if(isset($recents['metadata'])){ //fix an old bug unset($recents['metadata']); $this->internalSaveRecent(json_encode($recents)); } @@ -229,7 +230,8 @@ * @NoCSRFRequired */ public function getKeywordsDB() { - + if(!$this->CarnetFolder->nodeExists("quickdoc/keywords/keywordsnc")) + $this->mergeKeywordsDB(); return json_decode($this->getKeywordsDBFile()->getContent(),true); } @@ -325,9 +327,13 @@ public function getOpusEncoder(){ * @NoCSRFRequired */ public function mergeKeywordsDB() { + $lastmod = 0; + if(!$this->CarnetFolder->nodeExists("quickdoc/keywords/keywordsnc")) + $lastmod = -1; $myDb = $this->getKeywordsDBFile(); $hasChanged = false; - $lastmod = $myDb->getMTime(); + if($lastmod != -1) + $lastmod = $myDb->getMTime(); foreach($this->CarnetFolder->get("quickdoc/keywords/")->getDirectoryListing() as $inDB){ if($inDB->getName() === $myDb->getName()||$inDB->getMTime()<$lastmod){ continue; @@ -338,7 +344,7 @@ public function getOpusEncoder(){ foreach($thisDbContent->data as $action){ $isIn = false; foreach($myDbContent->data as $actionMy){ - if($actionMy->keyword === $action->keyword && $actionMy->time === $action->time && $actionMy->path === $action->path && $actionMy->action === $action->action){ + if($actionMy == $action){ $isIn = true; break; } |