diff options
author | Phie <phie@phie.ovh> | 2019-12-13 22:16:54 +0300 |
---|---|---|
committer | Phie <phie@phie.ovh> | 2019-12-13 22:16:54 +0300 |
commit | bbc30fcb8aea65195d291866aadf3a57435aa4bb (patch) | |
tree | 5ae79efca7b0f5cb66b3f41d24cd24dc39868b6a /lib | |
parent | 1c2127120d91220e583b0ec51bff385e622bd0b0 (diff) |
handle note folder in file hooker
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Hooks/FSHooks.php | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/Hooks/FSHooks.php b/lib/Hooks/FSHooks.php index 3873dbc..9287c74 100644 --- a/lib/Hooks/FSHooks.php +++ b/lib/Hooks/FSHooks.php @@ -39,15 +39,24 @@ class FSHooks { } } - private function isMine($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 - - - if(substr($node->getPath(), 0, strlen($this->carnetFolder->getPath())) === $this->carnetFolder->getPath()){ - - return true; + private function getSQDNode($node){ + if(substr($node->getName(), -3) === "sqd") + return $node; + $parent = $node->getParent(); + if($parent != NULL){ + if($parent->getName() === "data"){ + $parent = $parent->getParent(); } + if(substr($parent->getName(), -3) === "sqd"){ + return $parent; + } + } + return false; + } + + private function isMine($node){ + if(substr($node->getPath(), 0, strlen($this->carnetFolder->getPath())) === $this->carnetFolder->getPath()){ + return true; } return false; } @@ -66,7 +75,9 @@ class FSHooks { } if($this->isMine($node)){ try{ - + $node = $this->getSQDNode($node); + if(!$node) + return; $relativePath = $this->getRelativePath($node->getPath()); $cacheManager = new CacheManager($this->db, $this->carnetFolder); $utils = new NoteUtils(); |