Fix editing a file through gave not found error if the symlink was in a versioned directory

This commit is contained in:
nathangray 2018-03-15 14:46:36 -06:00
parent 98b2f3f4d3
commit 6be5b8f678

View File

@ -449,22 +449,8 @@ class Sharing
}
else
{
if(parse_url($path, PHP_URL_SCHEME) !== 'vfs')
{
$path = 'vfs://default'.($path[0] == '/' ? '' : '/').$path;
}
if (($exists = ($stat = Vfs::stat($path)) && Vfs::check_access($path, Vfs::READABLE, $stat)))
{
if (!preg_match("/^(sqlfs|vfs)/", $stat['url']))
{
$vfs_path = Vfs::parse_url($path, PHP_URL_PATH);
}
else
{
$vfs_path = Vfs::parse_url($stat['url'], PHP_URL_PATH);
}
}
$vfs_path = static::resolve_path($path);
$exists = !!($vfs_path);
}
// check if file exists and is readable
if (!$exists)
@ -569,6 +555,36 @@ class Sharing
return $share;
}
/**
* Get the actual VFS path for the given path
*
* We follow links & resolve whatever is possible so that when the share is
* mounted later (possibly by anonymous) the file can be found.
*
* @param string $path
* @return string
*/
public static function resolve_path($path)
{
$vfs_path = $path;
if(parse_url($path, PHP_URL_SCHEME) !== 'vfs')
{
$path = 'vfs://default'.($path[0] == '/' ? '' : '/').$path;
}
if (($exists = ($stat = Vfs::stat($path)) && Vfs::check_access($path, Vfs::READABLE, $stat)))
{
if (!preg_match("/^(sqlfs|vfs|stylite\.versioning)/", $stat['url']))
{
$vfs_path = Vfs::parse_url($path, PHP_URL_PATH);
}
else
{
$vfs_path = Vfs::parse_url($stat['url'], PHP_URL_PATH);
}
}
return $vfs_path;
}
/**
* Api\Storage\Base instance for egw_sharing table
*