diff --git a/api/src/Vfs.php b/api/src/Vfs.php index 41e321b7da..ce07fdbdf2 100644 --- a/api/src/Vfs.php +++ b/api/src/Vfs.php @@ -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(); diff --git a/api/src/Vfs/Sharing.php b/api/src/Vfs/Sharing.php index d9f4b71ed8..7706bc5dc3 100644 --- a/api/src/Vfs/Sharing.php +++ b/api/src/Vfs/Sharing.php @@ -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 diff --git a/api/src/Vfs/Sqlfs/StreamWrapper.php b/api/src/Vfs/Sqlfs/StreamWrapper.php index 8cb897f917..e9e898725b 100644 --- a/api/src/Vfs/Sqlfs/StreamWrapper.php +++ b/api/src/Vfs/Sqlfs/StreamWrapper.php @@ -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 */