some fixes for sqlfs fsck: caseinsensitive GROUP BY for MySQL, deleting files direct in DB, as self::unlink() fails if fs_active=0, and some more

This commit is contained in:
Ralf Becker 2012-02-27 14:34:18 +00:00
parent c603e3a1a6
commit 618ff70e73
3 changed files with 18 additions and 12 deletions

View File

@ -171,7 +171,7 @@ class admin_prefs_sidebox_hooks
$content .= html::form('<p>'.($check_only&&is_array($msgs)?html::submit_button('fix', lang('Fix reported problems')):'').
html::submit_button('cancel', lang('Cancel'), "window.location.href='".egw::link('/admin/index.php')."'; return false;").'</p>',
'',egw::link('/index.php',array('menuaction'=>'admin.admin_prefs_sidebox_hooks.fsck')));
'','/index.php',array('menuaction'=>'admin.admin_prefs_sidebox_hooks.fsck'));
$GLOBALS['egw']->framework->render($content, lang('Admin').' - '.lang('Check virtual filesystem'), true);
}

View File

@ -1540,7 +1540,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
return $stat;
}
private static $pdo_type;
public static $pdo_type;
/**
* Case sensitive comparison operator, for mysql we use ' COLLATE utf8_bin ='
*

View File

@ -127,23 +127,30 @@ class sqlfs_utils extends sqlfs_stream_wrapper
{
if (!file_exists($phy_path=self::_fs_path($row['fs_id'])))
{
egw_vfs::$is_root = true;
$path = self::id2path($row['fs_id']);
if ($check_only)
{
$msgs[] = lang('File %1 has no content in physical filesystem %2!',
$path.' (#'.$row['fs_id'].')',$phy_path);
}
elseif (self::unlink($path.'?storage=db')) // storage=db to not try to delete not existing phy. file
{
$msgs[] = lang('File %1 has no content in physical filesystem %2 --> file removed!',$path,$phy_path);
}
else
{
$msgs[] = lang('File %1 has no content in physical filesystem %2 --> failed to remove file!',
$path.' (#'.$row['fs_id'].')',$phy_path);
if (!isset($stmt))
{
$stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id');
$stmt_props = self::$pdo->prepare('DELETE FROM '.self::PROPS_TABLE.' WHERE fs_id=:fs_id');
}
if ($stmt->execute(array('fs_id' => $row['fs_id'])) &&
$stmt_props->execute(array('fs_id' => $row['fs_id'])))
{
$msgs[] = lang('File %1 has no content in physical filesystem %2 --> file removed!',$path,$phy_path);
}
else
{
$msgs[] = lang('File %1 has no content in physical filesystem %2 --> failed to remove file!',
$path.' (#'.$row['fs_id'].')',$phy_path);
}
}
egw_vfs::$is_root = false;
}
}
if ($check_only && $msgs)
@ -226,7 +233,6 @@ class sqlfs_utils extends sqlfs_stream_wrapper
if ($check_only && $msgs)
{
$msgs[] = lang('Unconnected nodes will be moved to %1.',self::LOST_N_FOUND);
continue;
}
return $msgs;
}
@ -242,7 +248,7 @@ class sqlfs_utils extends sqlfs_stream_wrapper
$msgs = array();
foreach(self::$pdo->query('SELECT fs_dir,fs_name,COUNT(*) FROM '.self::TABLE.
' WHERE fs_active='.self::_pdo_boolean(true).
' GROUP BY fs_dir,fs_name'.
' GROUP BY fs_dir,'.(self::$pdo_type == 'mysql' ? 'BINARY ' : '').'fs_name'. // fs_name is casesensitive!
' HAVING COUNT(*) > 1') as $row)
{
if (!isset($stmt))