diff options
author | Phie <phie@phie.ovh> | 2019-03-07 18:30:27 +0300 |
---|---|---|
committer | Phie <phie@phie.ovh> | 2019-03-07 18:30:27 +0300 |
commit | 57fc475621f65534c1786b5020a66efab6144895 (patch) | |
tree | e2da77bc3c849c5198ac32135c0b4cdbf2021ef0 /lib | |
parent | d6695df273f62510b4c6e1004710c51e77b1e926 (diff) |
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/Controller/NoteController.php | 9 | ||||
-rw-r--r-- | lib/Hooks/FSHooks.php | 7 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/Controller/NoteController.php b/lib/Controller/NoteController.php index 1b96838..cb78e8c 100755 --- a/lib/Controller/NoteController.php +++ b/lib/Controller/NoteController.php @@ -17,14 +17,16 @@ return $this->inputStream; } } + $test = "bla"; class NoteController extends Controller { private $userId; private $bla; private $storage; private $CarnetFolder; private $db; + public static $lastWrite = null; public function __construct($AppName, IRequest $request, $UserId, $RootFolder, $Config, IDBConnection $IDBConnection){ - parent::__construct($AppName, $request); + parent::__construct($AppName, $request); $this->userId = $UserId; $this->db = $IDBConnection; $this->Config = $Config; @@ -441,7 +443,7 @@ if(empty($path)) continue; try{ - if(!array_key_exists($path, $metadataFromCache)|| True){ + if(!array_key_exists($path, $metadataFromCache)){ $utils = new NoteUtils(); $meta = $utils->getMetadata($this->CarnetFolder, $path); $array[$path] = $meta; @@ -650,6 +652,7 @@ $folder = $cache->get("currentnote".$id); $zipFile = new MyZipFile(); $this->addFolderContentToArchive($folder,$zipFile,""); + //self::$lastWrite = $this->CarnetFolder->getPath()."/".$path; //to avoid FSHooks rewrite of metadata $file = $this->CarnetFolder->newFile($path); //tried to do with a direct fopen on $file but lead to bad size on nextcloud $tmppath = tempnam(sys_get_temp_dir(), uniqid().".sqd"); @@ -660,6 +663,8 @@ $this->CarnetFolder->get($path)->delete(); } catch(\OCP\Files\NotFoundException $e) { } + //self::$lastWrite = $file->getPath(); + $file->putContent($tmph); fclose($tmph); } else diff --git a/lib/Hooks/FSHooks.php b/lib/Hooks/FSHooks.php index 5fabc0c..45d902d 100644 --- a/lib/Hooks/FSHooks.php +++ b/lib/Hooks/FSHooks.php @@ -3,7 +3,7 @@ namespace OCA\Carnet\Hooks; use OCP\IUserManager; use OCA\Carnet\Misc\CacheManager; use OCA\Carnet\Misc\NoteUtils; - +use OCA\Carnet\Controller\NoteController; use OCP\IDBConnection; class FSHooks { @@ -27,7 +27,7 @@ class FSHooks { } public function postWrite($node) { - + if(substr($node->getName(), -3) === "sqd"){ // to avoid getting carnet's path each time a file is writen //we check if is in our path @@ -35,6 +35,9 @@ class FSHooks { $relativePath = substr($node->getPath(), strlen($this->carnetFolder->getPath())); if(substr($relativePath, 0, 1) === "/") $relativePath = substr($relativePath, 1); + /*if(NoteController::$lastWrite === $node->getPath()){ + return; //was already handled in save + }*/ $cacheManager = new CacheManager($this->db); $utils = new NoteUtils(); $metadata = $utils->getMetadata($this->carnetFolder, $relativePath); |