some fixes for Collabora on mounted shares

This commit is contained in:
Ralf Becker 2020-09-23 22:01:11 +02:00
parent ff50af5677
commit 6af5e99a1c
2 changed files with 25 additions and 3 deletions

View File

@ -336,7 +336,7 @@ class Vfs extends Vfs\Base
* - hidden => {true|false(default)} include hidden files (name starts with a '.' or is Thumbs.db)
* - show-deleted => {true|false(default)} get also set by hidden, if not explicitly set otherwise (requires versioning!)
* </code>
* @param string|array/true $exec =null function to call with each found file/dir as first param and stat array as last param or
* @param string|array|true $exec =null function to call with each found file/dir as first param and stat array as last param or
* true to return file => stat pairs
* @param array $exec_params =null further params for exec as array, path is always the first param and stat the last!
* @return array of pathes if no $exec, otherwise path => stat pairs
@ -793,7 +793,7 @@ class Vfs extends Vfs\Base
return $ret;
}
if (!isset($vfs)) $vfs = new Vfs\StreamWrapper();
if (!isset($vfs)) $vfs = new Vfs\StreamWrapper($path);
return $vfs->check_access($path, $check, $stat);
}
@ -2074,7 +2074,7 @@ class Vfs extends Vfs\Base
*/
static function resolve_url_symlinks($_path,$file_exists=true,$resolve_last_symlink=true,&$stat=null)
{
$vfs = new Vfs\StreamWrapper();
$vfs = new Vfs\StreamWrapper($_path);
return $vfs->resolve_url_symlinks($_path, $file_exists, $resolve_last_symlink, $stat);
}

View File

@ -209,6 +209,28 @@ trait UserContextTrait
}
}
/**
* Get user context for given url, eg. to use with regular stream functions
*
* @param string $url
* @param array $extra =[] addtional context options
* @return resource context with user, plus optional extra options
*/
public static function userContext($url, array $extra=[])
{
if (($user = Vfs::parse_url($url, PHP_URL_USER)) &&
($account_id = Api\Accounts::getInstance()->name2id($user)) &&
($account_id != Vfs::$user) || $extra) // never set extra options on default context!
{
$context = stream_context_create(array_merge_recursive([Vfs::SCHEME => ['user' => (int)$account_id ?: Vfs::$user]], $extra));
}
else
{
$context = stream_context_get_default();
}
return $context;
}
/**
* @param string $name
* @return bool