call notification hook for unlink/rmdir only after successful removal, but with (not longer existing) stat data

This commit is contained in:
Ralf Becker 2012-04-19 13:18:19 +00:00
parent 0976a3f918
commit d5972cd30c

View File

@ -450,17 +450,22 @@ class vfs_stream_wrapper implements iface_stream_wrapper
{ {
return false; return false;
} }
// call "vfs_unlink" hook, before unlink $stat = self::url_stat($path, STREAM_URL_STAT_LINK);
if (isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks))
self::symlinkCache_remove($path);
$ok = unlink($url);
// call "vfs_unlink" hook only after successful unlink, with data from (not longer possible) stat call
if ($ok && isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks))
{ {
$GLOBALS['egw']->hooks->process(array( $GLOBALS['egw']->hooks->process(array(
'location' => 'vfs_unlink', 'location' => 'vfs_unlink',
'path' => $path[0] == '/' ? $path : parse_url($path, PHP_URL_PATH), 'path' => $path[0] == '/' ? $path : parse_url($path, PHP_URL_PATH),
'url' => $url, 'url' => $url,
'stat' => $stat,
),'',true); ),'',true);
} }
self::symlinkCache_remove($path); return $ok;
return unlink($url);
} }
/** /**
@ -564,17 +569,22 @@ class vfs_stream_wrapper implements iface_stream_wrapper
{ {
return false; return false;
} }
// call "vfs_rmdir" hook, before removing $stat = self::url_stat($path, STREAM_URL_STAT_LINK);
if (isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks))
self::symlinkCache_remove($path);
$ok = rmdir($url);
// call "vfs_rmdir" hook, only after successful rmdir
if ($ok && isset($GLOBALS['egw']) && isset($GLOBALS['egw']->hooks))
{ {
$GLOBALS['egw']->hooks->process(array( $GLOBALS['egw']->hooks->process(array(
'location' => 'vfs_rmdir', 'location' => 'vfs_rmdir',
'path' => $path[0] == '/' ? $path : parse_url($path, PHP_URL_PATH), 'path' => $path[0] == '/' ? $path : parse_url($path, PHP_URL_PATH),
'url' => $url, 'url' => $url,
'stat' => $stat,
),'',true); ),'',true);
} }
self::symlinkCache_remove($path); return $ok;
return rmdir($url);
} }
/** /**