summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-11-10 23:50:43 +0100
committerRobin Appelman <icewind1991@gmail.com>2011-11-10 23:50:43 +0100
commitb2f2a8774586a49dee066a1fef674b26c04c5755 (patch)
tree36a2e6942dfe10234f6c5d7e9d615d880f2faaa4 /lib
parent5a8235eca0c282d79d48f65a5419c6c855ecdc36 (diff)
downloadnextcloud-server-b2f2a8774586a49dee066a1fef674b26c04c5755.tar.gz
nextcloud-server-b2f2a8774586a49dee066a1fef674b26c04c5755.zip
use cache for searching files
Diffstat (limited to 'lib')
-rw-r--r--lib/filecache.php6
-rw-r--r--lib/filesystem.php16
2 files changed, 10 insertions, 12 deletions
diff --git a/lib/filecache.php b/lib/filecache.php
index 902a8052afc..db3d6ca1d5b 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -62,6 +62,7 @@ class OC_FileCache{
$path=OC_Filesystem::getRoot().$path;
if($id=self::getFileId($path)!=-1){
self::update($id,$data);
+ return;
}
if($path=='/'){
$parent=-1;
@@ -115,9 +116,9 @@ class OC_FileCache{
* @param string $query
* @return array of filepaths
*/
- public static function search($query){
+ public static function search($search){
$query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE name LIKE ?');
- $result=$query->execute(array("%$query%"));
+ $result=$query->execute(array("%$search%"));
$names=array();
while($row=$result->fetchRow()){
$names[]=$row['path'];
@@ -330,4 +331,3 @@ class OC_FileCache{
OC_Hook::connect('OC_Filesystem','post_write','OC_FileCache','fileSystemWatcherWrite');
OC_Hook::connect('OC_Filesystem','delete','OC_FileCache','fileSystemWatcherDelete');
OC_Hook::connect('OC_Filesystem','rename','OC_FileCache','fileSystemWatcherRename');
-
diff --git a/lib/filesystem.php b/lib/filesystem.php
index 93f52423332..c3830b34168 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -390,15 +390,13 @@ class OC_Filesystem{
$files=array();
$fakeRoot=self::$fakeRoot;
$fakeRootLength=strlen($fakeRoot);
- foreach(self::$storages as $mountpoint=>$storage){
- $results=$storage->search($query);
- if(is_array($results)){
- foreach($results as $result){
- $file=str_replace('//','/',$mountpoint.$result);
- if(substr($file,0,$fakeRootLength)==$fakeRoot){
- $file=substr($file,$fakeRootLength);
- $files[]=$file;
- }
+ $results=OC_FileCache::search($query);
+ if(is_array($results)){
+ foreach($results as $result){
+ $file=str_replace('//','/',$mountpoint.$result);
+ if(substr($file,0,$fakeRootLength)==$fakeRoot){
+ $file=substr($file,$fakeRootLength);
+ $files[]=$file;
}
}
}