#1165 backup with errors fills up tmp-directories with lots of backup-files (retrofit from trunk)

SVN:2.1.0[3892]
This commit is contained in:
Romain Quetiez
2016-02-01 14:57:54 +00:00
parent 95d6b640b1
commit cc7f3d46a6
2 changed files with 46 additions and 39 deletions

View File

@@ -1,5 +1,5 @@
<?php <?php
// Copyright (C) 2010-2012 Combodo SARL // Copyright (C) 2010-2016 Combodo SARL
// //
// This file is part of iTop. // This file is part of iTop.
// //
@@ -224,6 +224,13 @@ class DBBackup
} }
if ($iRetCode != 0) if ($iRetCode != 0)
{ {
// Cleanup residual output (Happens with Error 2020: Got packet bigger than 'maxallowedpacket' bytes...)
if (file_exists($sBackupFileName))
{
unlink($sBackupFileName);
throw new Exception('Effacement du fichier '.$sTmpFileName);
}
$this->LogError("Failed to execute: $sCommandDisplay. The command returned:$iRetCode"); $this->LogError("Failed to execute: $sCommandDisplay. The command returned:$iRetCode");
foreach($aOutput as $sLine) foreach($aOutput as $sLine)
{ {

View File

@@ -1,5 +1,5 @@
<?php <?php
// Copyright (C) 2010-2013 Combodo SARL // Copyright (C) 2010-2016 Combodo SARL
// //
// This file is part of iTop. // This file is part of iTop.
// //
@@ -19,7 +19,7 @@
/** /**
* Heart beat of the application (process asynchron tasks such as broadcasting email) * Heart beat of the application (process asynchron tasks such as broadcasting email)
* *
* @copyright Copyright (C) 2010-2013 Combodo SARL * @copyright Copyright (C) 2010-2016 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0 * @license http://opensource.org/licenses/AGPL-3.0
*/ */
@@ -70,12 +70,17 @@ function UsageAndExit($oP)
} }
function RunTask($oProcess, BackgroundTask $oTask, $oStartDate, $iTimeLimit) function RunTask($oProcess, BackgroundTask $oTask, $oStartDate, $iTimeLimit)
{
try
{ {
$oNow = new DateTime(); $oNow = new DateTime();
$fStart = microtime(true); $fStart = microtime(true);
try
{
$sMessage = $oProcess->Process($iTimeLimit); $sMessage = $oProcess->Process($iTimeLimit);
}
catch(Exception $e)
{
$sMessage = 'Processing failed with message: '.$e->getMessage();
}
$fDuration = microtime(true) - $fStart; $fDuration = microtime(true) - $fStart;
if ($oTask->Get('total_exec_count') == 0) if ($oTask->Get('total_exec_count') == 0)
{ {
@@ -108,11 +113,6 @@ function RunTask($oProcess, BackgroundTask $oTask, $oStartDate, $iTimeLimit)
$oTask->Set('next_run_date', $oPlannedStart->format('Y-m-d H:i:s')); $oTask->Set('next_run_date', $oPlannedStart->format('Y-m-d H:i:s'));
$oTask->DBUpdate(); $oTask->DBUpdate();
}
catch(Exception $e)
{
$sMessage = 'Processing failed, the following exception occured: '.$e->getMessage();
}
return $sMessage; return $sMessage;
} }