Skip to content

Commit

Permalink
Fix: Better error management in export
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 7, 2011
1 parent 5741b19 commit 52ee718
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions htdocs/admin/tools/export.php
Expand Up @@ -164,12 +164,14 @@

if ($handle)
{
$ok=0;
dol_syslog("Run command ".$fullcommandcrypted);
$handlein = popen($fullcommandclear, 'r');
while (!feof($handlein))
{
$read = fgets($handlein);
fwrite($handle,$read);
if (preg_match('/-- Dump completed/i',$read)) $ok=1;
}
pclose($handlein);

Expand All @@ -187,7 +189,6 @@
$errormsg=$langs->trans("ErrorFailedToWriteInDir");
}
// Get errorstring
// TODO Scan full file instead of 2048 first char to search for "-- dump completed"
if ($compression == 'none') $handle = fopen($outputfile, 'r');
if ($compression == 'gz') $handle = gzopen($outputfile, 'r');
if ($compression == 'bz') $handle = bzopen($outputfile, 'r');
Expand All @@ -199,7 +200,7 @@
if ($compression == 'none') fclose($handle);
if ($compression == 'gz') gzclose($handle);
if ($compression == 'bz') bzclose($handle);
if (preg_match('/^-- MySql/i',$errormsg)) $errormsg=''; // Pas erreur
if ($ok && preg_match('/^-- MySql/i',$errormsg)) $errormsg=''; // Pas erreur
else
{
// Renommer fichier sortie en fichier erreur
Expand Down

0 comments on commit 52ee718

Please sign in to comment.