diff options
author | Phie <phie@phie.ovh> | 2019-04-16 22:41:17 +0300 |
---|---|---|
committer | Phie <phie@phie.ovh> | 2019-04-16 22:41:17 +0300 |
commit | 712e9161c1a2627661b7bb6d8550295c295a3c02 (patch) | |
tree | 2e81a4794f05577011fe3a70792f77468bb37977 | |
parent | b1648bab7043fae169aebd8031461fa2c2ad0a51 (diff) |
fix first launch + fix save metadata to cache
-rwxr-xr-x | lib/Controller/NoteController.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Controller/NoteController.php b/lib/Controller/NoteController.php index e5feea7..6d2bdf2 100755 --- a/lib/Controller/NoteController.php +++ b/lib/Controller/NoteController.php @@ -121,6 +121,8 @@ $recents = json_decode($this->getRecentFile()->getContent(),true); $paths = array(); + if($recents['data'] == null) + $recents['data'] = array(); foreach($recents['data'] as $item){ $path = $item['path']; if($item['newpath'] != null) @@ -129,11 +131,13 @@ array_push($paths, $path); } - - $cache = new CacheManager($this->db, $this->CarnetFolder); - $metadataFromCache = $cache->getFromCache($paths); - $return = array(); - $return['metadata'] = $metadataFromCache; + if(sizeof($paths)>0){ + $cache = new CacheManager($this->db, $this->CarnetFolder); + $metadataFromCache = $cache->getFromCache($paths); + $return = array(); + $return['metadata'] = $metadataFromCache; + } + $return['data'] = $recents['data']; return $return; } @@ -732,7 +736,7 @@ $file->putContent($tmph); fclose($tmph); - $meta['metadata'] = $folder->get("metadata.json")->getContent(); + $meta['metadata'] = json_decode($folder->get("metadata.json")->getContent()); $meta['shorttext'] = NoteUtils::getShortTextFromHTML($folder->get("index.html")->getContent()); $cache = new CacheManager($this->db, $this->CarnetFolder); $cache->addToCache($path, $meta, $file->getFileInfo()->getMtime()); |