diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-01-31 16:12:49 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-01-31 16:12:49 +0100 |
commit | c46f701771db9285e70a5b1d5a4b641046bf703c (patch) | |
tree | 2c020015d04ede4be9f158d48a36c1eb158c0e72 /lib/filecache.php | |
parent | df67c35017d8794a4b1c83fd4e41658b2e6d0e75 (diff) | |
download | nextcloud-server-c46f701771db9285e70a5b1d5a4b641046bf703c.tar.gz nextcloud-server-c46f701771db9285e70a5b1d5a4b641046bf703c.zip |
use filesystem cache for searching
Diffstat (limited to 'lib/filecache.php')
-rw-r--r-- | lib/filecache.php | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/filecache.php b/lib/filecache.php index 6dbaef4bbfa..689680624a4 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -79,8 +79,9 @@ class OC_FileCache{ $data['versioned']=false; } $mimePart=dirname($data['mimetype']); - $query=OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart) VALUES(?,?,?,?,?,?,?,?)'); - $query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart)); + $user=OC_User::getUser(); + $query=OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart,user) VALUES(?,?,?,?,?,?,?,?,?)'); + $query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user)); } @@ -133,14 +134,26 @@ class OC_FileCache{ /** * return array of filenames matching the querty * @param string $query + * @param boolean $returnData * @return array of filepaths */ - public static function search($search){ - $query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE name LIKE ?'); - $result=$query->execute(array("%$search%")); + public static function search($search,$returnData=false){ + $root=OC_Filesystem::getRoot(); + $rootLen=strlen($root); + if(!$returnData){ + $query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE name LIKE ? AND user=?'); + }else{ + $query=OC_DB::prepare('SELECT * FROM *PREFIX*fscache WHERE name LIKE ? AND user=?'); + } + $result=$query->execute(array("%$search%",OC_User::getUser())); $names=array(); while($row=$result->fetchRow()){ - $names[]=$row['path']; + if(!$returnData){ + $names[]=substr($row['path'],$rootLen); + }else{ + $row['path']=substr($row['path'],$rootLen); + $names[]=$row; + } } return $names; } |