use cache for searching files
This commit is contained in:
parent
5a8235eca0
commit
b2f2a87745
|
@ -62,6 +62,7 @@ class OC_FileCache{
|
||||||
$path=OC_Filesystem::getRoot().$path;
|
$path=OC_Filesystem::getRoot().$path;
|
||||||
if($id=self::getFileId($path)!=-1){
|
if($id=self::getFileId($path)!=-1){
|
||||||
self::update($id,$data);
|
self::update($id,$data);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if($path=='/'){
|
if($path=='/'){
|
||||||
$parent=-1;
|
$parent=-1;
|
||||||
|
@ -115,9 +116,9 @@ class OC_FileCache{
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @return array of filepaths
|
* @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 ?');
|
$query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE name LIKE ?');
|
||||||
$result=$query->execute(array("%$query%"));
|
$result=$query->execute(array("%$search%"));
|
||||||
$names=array();
|
$names=array();
|
||||||
while($row=$result->fetchRow()){
|
while($row=$result->fetchRow()){
|
||||||
$names[]=$row['path'];
|
$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','post_write','OC_FileCache','fileSystemWatcherWrite');
|
||||||
OC_Hook::connect('OC_Filesystem','delete','OC_FileCache','fileSystemWatcherDelete');
|
OC_Hook::connect('OC_Filesystem','delete','OC_FileCache','fileSystemWatcherDelete');
|
||||||
OC_Hook::connect('OC_Filesystem','rename','OC_FileCache','fileSystemWatcherRename');
|
OC_Hook::connect('OC_Filesystem','rename','OC_FileCache','fileSystemWatcherRename');
|
||||||
|
|
||||||
|
|
|
@ -390,8 +390,7 @@ class OC_Filesystem{
|
||||||
$files=array();
|
$files=array();
|
||||||
$fakeRoot=self::$fakeRoot;
|
$fakeRoot=self::$fakeRoot;
|
||||||
$fakeRootLength=strlen($fakeRoot);
|
$fakeRootLength=strlen($fakeRoot);
|
||||||
foreach(self::$storages as $mountpoint=>$storage){
|
$results=OC_FileCache::search($query);
|
||||||
$results=$storage->search($query);
|
|
||||||
if(is_array($results)){
|
if(is_array($results)){
|
||||||
foreach($results as $result){
|
foreach($results as $result){
|
||||||
$file=str_replace('//','/',$mountpoint.$result);
|
$file=str_replace('//','/',$mountpoint.$result);
|
||||||
|
@ -401,7 +400,6 @@ class OC_Filesystem{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return $files;
|
return $files;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue