]> source.dussan.org Git - nextcloud-server.git/commitdiff
also delete childs of folders from the cache
authorRobin Appelman <icewind@owncloud.com>
Sat, 3 Mar 2012 17:23:53 +0000 (18:23 +0100)
committerRobin Appelman <icewind@owncloud.com>
Sat, 3 Mar 2012 20:23:35 +0000 (21:23 +0100)
lib/filecache.php

index e94ae49c73ac044da0ff3030051ef3bac8773b50..be2a00a19a0a94e82f913e2e835f1a264be46d0f 100644 (file)
@@ -168,19 +168,28 @@ class OC_FileCache{
 
        /**
         * delete info from the cache
-        * @param string $path
+        * @param string/int $file
         * @param string root (optional)
         */
-       public static function delete($path,$root=''){
-               if(!$root){
-                       $root=OC_Filesystem::getRoot();
-               }
-               if($root=='/'){
-                       $root='';
+       public static function delete($file,$root=''){
+               if(!is_numeric($file)){
+                       if(!$root){
+                               $root=OC_Filesystem::getRoot();
+                       }
+                       if($root=='/'){
+                               $root='';
+                       }
+                       $path=$root.$file;
+                       self::delete(self::getFileId($path));
+               }elseif($file!=-1){
+                       $query=OC_DB::prepare('SELECT id FROM *PREFIX*fscache WHERE parent=?');
+                       $query->execute(array($file));
+                       while($child=$query->fetchRow()){
+                               self::delete(intval($child['id']));
+                       }
+                       $query=OC_DB::prepare('DELETE FROM *PREFIX*fscache WHERE id=?');
+                       $query->execute(array($file));
                }
-               $path=$root.$path;
-               $query=OC_DB::prepare('DELETE FROM *PREFIX*fscache WHERE path=?');
-               $query->execute(array($path));
        }
        
        /**