Finally fixed creation and rename of home directories:

- egw_vfs::stat and egw_vfs_stream_wrapper::url_stat now both have a
  parameter $try_create_home=false, which do not create a non-existing
  home-directory by default.
- filemanger_ui calls egw_vfs::stat($path,true) to create an evtl.
  missing home dir (in case it does not exist because of previous
  problems)
--> fixes not working home-dir creation or rename, because url_stat
    already tried to create the home-dir
This commit is contained in:
Ralf Becker 2009-04-06 13:46:45 +00:00
parent 979466c1fc
commit fcb8f3497c
4 changed files with 14 additions and 13 deletions

View File

@ -102,7 +102,7 @@ class filemanager_ui
if (isset($_GET['msg'])) $msg = $_GET['msg'];
if (isset($_GET['path']) && ($path = $_GET['path']))
{
if ($path[0] == '/' && egw_vfs::is_dir($path) && egw_vfs::check_access($path,egw_vfs::READABLE))
if ($path[0] == '/' && egw_vfs::stat($path,true) && egw_vfs::is_dir($path) && egw_vfs::check_access($path,egw_vfs::READABLE))
{
$content['nm']['path'] = $path;
}
@ -224,7 +224,7 @@ class filemanager_ui
break;
}
}
if (!egw_vfs::is_dir($content['nm']['path']))
if (!egw_vfs::stat($content['nm']['path'],true) || !egw_vfs::is_dir($content['nm']['path']))
{
$content['nm']['msg'] .= ' '.lang('Directory not found or no permission to access it!');
}
@ -489,7 +489,7 @@ class filemanager_ui
{
$GLOBALS['egw']->session->appsession('index','filemanager',$query);
if (!egw_vfs::is_dir($query['path']) || !egw_vfs::check_access($query['path'],egw_vfs::READABLE))
if (!egw_vfs::stat($query['path'],true) || !egw_vfs::is_dir($query['path']) || !egw_vfs::check_access($query['path'],egw_vfs::READABLE))
{
// we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give
// an appropriate message

View File

@ -169,15 +169,16 @@ class egw_vfs extends vfs_stream_wrapper
* stat working on just the eGW VFS (alias of url_stat)
*
* @param string $path filename with absolute path in the eGW VFS
* @param boolean $try_create_home=false should a non-existing home-directory be automatically created
* @return array
*/
static function stat($path)
static function stat($path,$try_create_home=false)
{
if ($path[0] != '/')
{
throw new egw_exception_assertion_failed("File '$path' is not an absolute path!");
}
if (($stat = self::url_stat($path,0)))
if (($stat = self::url_stat($path,0,$try_create_home)))
{
$stat = array_slice($stat,13); // remove numerical indices 0-12
}
@ -188,15 +189,16 @@ class egw_vfs extends vfs_stream_wrapper
* lstat (not resolving symbolic links) working on just the eGW VFS (alias of url_stat)
*
* @param string $path filename with absolute path in the eGW VFS
* @param boolean $try_create_home=false should a non-existing home-directory be automatically created
* @return array
*/
static function lstat($path)
static function lstat($path,$try_create_home=false)
{
if ($path[0] != '/')
{
throw new egw_exception_assertion_failed("File '$path' is not an absolute path!");
}
if (($stat = self::url_stat($path,STREAM_URL_STAT_LINK)))
if (($stat = self::url_stat($path,STREAM_URL_STAT_LINK,$try_create_home)))
{
$stat = array_slice($stat,13); // remove numerical indices 0-12
}

View File

@ -41,7 +41,7 @@ class vfs_home_hooks
if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')');
// create a user-dir
egw_vfs::$is_root = true;
if (@egw_vfs::mkdir($dir='/home/'.$data['account_lid'],0700,0))
if (egw_vfs::mkdir($dir='/home/'.$data['account_lid'],0700,0))
{
egw_vfs::chown($dir,$data['account_id']);
egw_vfs::chgrp($dir,0);
@ -109,7 +109,7 @@ class vfs_home_hooks
if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')');
// create a group-dir
egw_vfs::$is_root = true;
if (@egw_vfs::mkdir($dir='/home/'.$data['account_name'],070,0))
if (egw_vfs::mkdir($dir='/home/'.$data['account_name'],0070,0))
{
egw_vfs::chown($dir,0);
egw_vfs::chgrp($dir,$data['account_id']);

View File

@ -690,11 +690,11 @@ class vfs_stream_wrapper implements iface_stream_wrapper
* - STREAM_URL_STAT_QUIET If this flag is set, your wrapper should not raise any errors. If this flag is not set,
* you are responsible for reporting errors using the trigger_error() function during stating of the path.
* stat triggers it's own warning anyway, so it makes no sense to trigger one by our stream-wrapper!
* @param boolean $try_create_home=true should a user home-directory be created automatic, if it does not exist
* @param boolean $try_create_home=false should a user home-directory be created automatic, if it does not exist
* @param boolean $check_symlink_components=true check if path contains symlinks in path components other then the last one
* @return array
*/
static function url_stat ( $path, $flags, $try_create_home=true, $check_symlink_components=true )
static function url_stat ( $path, $flags, $try_create_home=false, $check_symlink_components=true )
{
if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path',$flags,try_create_home=$try_create_home,check_symlink_components=$check_symlink_components)");
@ -728,8 +728,7 @@ class vfs_stream_wrapper implements iface_stream_wrapper
}
}
// check if a failed url_stat was for a home dir, in that case silently create it
static $hook_data; // we have to make sure to not call ourself recursivly (eg. mkdir will call stat to make sure the dir does not yet exist!)
if (!$stat && is_null($hook_data) && dirname(parse_url($path,PHP_URL_PATH)) == '/home' &&
if (!$stat && $try_create_home && dirname(parse_url($path,PHP_URL_PATH)) == '/home' &&
($id = $GLOBALS['egw']->accounts->name2id(basename($path))) &&
$GLOBALS['egw']->accounts->id2name($id) == basename($path)) // make sure path has the right case!
{