add public api to get the file id from the cache
This commit is contained in:
parent
c5b8a3eb94
commit
a6a8e2c553
1 changed files with 34 additions and 0 deletions
|
@ -281,6 +281,7 @@ class OC_FileCache{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the file id as used in the cache
|
* get the file id as used in the cache
|
||||||
|
* unlike the public getId, full paths are used here (/usename/files/foo instead of /foo)
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@ -303,6 +304,39 @@ class OC_FileCache{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the file id as used in the cache
|
||||||
|
* @param string path
|
||||||
|
* @param string root (optional)
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getId($path,$root=''){
|
||||||
|
if(!$root){
|
||||||
|
$root=OC_Filesystem::getRoot();
|
||||||
|
}
|
||||||
|
if($root=='/'){
|
||||||
|
$root='';
|
||||||
|
}
|
||||||
|
$path=$root.$path;
|
||||||
|
return self::getFileId($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the file path from the id, relative to the home folder of the user
|
||||||
|
* @param int id
|
||||||
|
* @param string user (optional)
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getPath($id,$user=''){
|
||||||
|
if(!$user){
|
||||||
|
$user=OC_User::getUser();
|
||||||
|
}
|
||||||
|
$query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE id=? AND user=?');
|
||||||
|
$result=$query->execute(array($id,$user));
|
||||||
|
$row=$result->fetchRow();
|
||||||
|
return $row['path'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the file id of the parent folder, taking into account '/' has no parent
|
* get the file id of the parent folder, taking into account '/' has no parent
|
||||||
|
|
Loading…
Reference in a new issue