Skip to content
Snippets Groups Projects
Commit bcebfbfb authored by Robin Appelman's avatar Robin Appelman
Browse files

bugfix in searching files by mimetype

parent 36d696c3
Branches
No related tags found
No related merge requests found
...@@ -466,6 +466,7 @@ class OC_FileCache{ ...@@ -466,6 +466,7 @@ class OC_FileCache{
* fine files by mimetype * fine files by mimetype
* @param string $part1 * @param string $part1
* @param string $part2 (optional) * @param string $part2 (optional)
* @param string root (optional)
* @return array of file paths * @return array of file paths
* *
* $part1 and $part2 together form the complete mimetype. * $part1 and $part2 together form the complete mimetype.
...@@ -474,17 +475,24 @@ class OC_FileCache{ ...@@ -474,17 +475,24 @@ class OC_FileCache{
* seccond mimetype part can be ommited * seccond mimetype part can be ommited
* e.g. searchByMime('audio') * e.g. searchByMime('audio')
*/ */
public static function searchByMime($part1,$part2=''){ public static function searchByMime($part1,$part2='',$root=''){
if($part2){ if(!$root){
$query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE mimepart=?'); $root=OC_Filesystem::getRoot();
$result=$query->execute(array($part1)); }elseif($root='/'){
$root='';
}
$rootLen=strlen($root);
$user=OC_User::getUser();
if(!$part2){
$query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE mimepart=? AND user=?');
$result=$query->execute(array($part1,$user));
}else{ }else{
$query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE mimetype=?'); $query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE mimetype=? AND user=?');
$result=$query->execute(array($part1.'/'.$part2)); $result=$query->execute(array($part1.'/'.$part2,$user));
} }
$names=array(); $names=array();
while($row=$result->fetchRow()){ while($row=$result->fetchRow()){
$names[]=$row['path']; $names[]=substr($row['path'],$rootLen);
} }
return $names; return $names;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment