forked from extern/egroupware
Add a function to get the lowest fs_id for a path
This commit is contained in:
parent
f42801236a
commit
90ce0cc7b6
@ -2562,6 +2562,22 @@ class Vfs
|
||||
|
||||
return $fp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lowest fs_id for a given path
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return integer|boolean Lowest fs_id for that path, or false
|
||||
*/
|
||||
static function get_minimum_file_id($path)
|
||||
{
|
||||
if(!self::file_exists($path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return self::_call_on_backend('get_minimum_file_id', array($path));
|
||||
}
|
||||
}
|
||||
|
||||
Vfs::init_static();
|
||||
|
@ -410,7 +410,8 @@ class Sharing
|
||||
{
|
||||
$path = 'vfs://default'.($path[0] == '/' ? '' : '/').$path;
|
||||
}
|
||||
$vfs_path = Vfs::parse_url($path, PHP_URL_PATH);
|
||||
$stat = Vfs::stat($path);
|
||||
$vfs_path = Vfs::parse_url($stat['url'], PHP_URL_PATH);
|
||||
$exists = Vfs::file_exists($vfs_path) && Vfs::is_readable($vfs_path);
|
||||
}
|
||||
// check if file exists and is readable
|
||||
|
@ -1555,6 +1555,36 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface
|
||||
return $eacls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lowest file id (fs_id) for a given path
|
||||
*
|
||||
* @param string $path
|
||||
* @return integer
|
||||
*/
|
||||
static function get_minimum_file_id($path)
|
||||
{
|
||||
$vfs = new self();
|
||||
$stat = $vfs->url_stat($path,0);
|
||||
$fs_id = (int)$stat['ino'];
|
||||
|
||||
$query = 'SELECT MIN(B.fs_id)
|
||||
FROM egroupware.egw_sqlfs as A
|
||||
JOIN egroupware.egw_sqlfs AS B ON
|
||||
A.fs_name = B.fs_name AND A.fs_dir = B.fs_dir AND A.fs_active = 1 && B.fs_active = 0
|
||||
WHERE A.fs_id=?
|
||||
GROUP BY A.fs_id';
|
||||
if (self::LOG_LEVEL > 2)
|
||||
{
|
||||
$query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
|
||||
}
|
||||
$stmt = self::$pdo->prepare($query);
|
||||
|
||||
$stmt->execute($fs_id);
|
||||
$min = $stmt->fetchColumn();
|
||||
|
||||
return $min ? $min : $fs_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Max allowed sub-directory depth, to be able to break infinit recursion by wrongly linked directories
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user