diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-03-03 18:23:53 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-03-03 21:23:35 +0100 |
commit | 0f540843058b869829a48f8d41abfff19b0862d4 (patch) | |
tree | c6ee0c00d7a4026157f9c8fc63347cae7b6b0d6a /lib/filecache.php | |
parent | 2e365658c856e1dffd1ee748db40158fdda0edc3 (diff) | |
download | nextcloud-server-0f540843058b869829a48f8d41abfff19b0862d4.tar.gz nextcloud-server-0f540843058b869829a48f8d41abfff19b0862d4.zip |
also delete childs of folders from the cache
Diffstat (limited to 'lib/filecache.php')
-rw-r--r-- | lib/filecache.php | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/filecache.php b/lib/filecache.php index e94ae49c73a..be2a00a19a0 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -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)); } /** |