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;
|
||||
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');
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue