checking if attachment or attachment dir exists, before trying to delete it, to quieten warning, also improved warning to be precise if file does not exist, is no directory, or permission missing

This commit is contained in:
Ralf Becker 2009-07-18 09:12:52 +00:00
parent 3d1cb839ce
commit 8fb60be7d7
2 changed files with 7 additions and 5 deletions

View File

@ -827,12 +827,12 @@ class egw_link extends solink
}
if (self::DEBUG)
{
echo "<p>egw_link::delete_attached('$app','$id','$fname') url=$url</p>\n";
echo '<p>'.__METHOD__."('$app','$id','$fname') url=$url</p>\n";
}
if (($Ok = egw_vfs::remove($url,true)) && ((int)$app > 0 || $fname))
if (($Ok = !file_exists($url) || egw_vfs::remove($url,true)) && ((int)$app > 0 || $fname))
{
// try removing the dir, in case it's empty
@rmdir(egw_vfs::dirname($url));
@egw_vfs::rmdir(egw_vfs::dirname($url));
}
if (!is_null($current_is_root))
{

View File

@ -695,10 +695,12 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
!egw_vfs::check_access($parent,egw_vfs::WRITABLE))
{
self::_remove_password($url);
if (self::LOG_LEVEL) error_log(__METHOD__."($url,$options) (type=$type) permission denied!");
$err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' :
($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!'));
if (self::LOG_LEVEL) error_log($err_msg);
if (!($options & STREAM_URL_STAT_QUIET))
{
trigger_error(__METHOD__."('$url',$options) (type=$type) permission denied!",E_USER_WARNING);
trigger_error($err_msg,E_USER_WARNING);
}
return false; // no permission or file does not exist
}