From 6be5b8f678d8dbc02bf45564ee4ded2470bcd2ad Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 15 Mar 2018 14:46:36 -0600 Subject: [PATCH] Fix editing a file through gave not found error if the symlink was in a versioned directory --- api/src/Vfs/Sharing.php | 48 +++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/api/src/Vfs/Sharing.php b/api/src/Vfs/Sharing.php index a6aab9e4ec..77ff240de3 100644 --- a/api/src/Vfs/Sharing.php +++ b/api/src/Vfs/Sharing.php @@ -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 *