From: Marcin Haba Date: Sat, 12 Dec 2015 19:30:10 +0000 (+0100) Subject: baculum: Remove temporary Bvfs table when restore starts X-Git-Tag: Release-7.4.0~144 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=476918c1b1ca7fa814a247592934eae0c6f0d90b;p=bacula%2Fbacula baculum: Remove temporary Bvfs table when restore starts --- diff --git a/gui/baculum/protected/Class/Miscellaneous.php b/gui/baculum/protected/Class/Miscellaneous.php index 9b1725d6bd..bb8a7170f6 100644 --- a/gui/baculum/protected/Class/Miscellaneous.php +++ b/gui/baculum/protected/Class/Miscellaneous.php @@ -20,6 +20,8 @@ class Miscellaneous extends TModule { const LICENCE_FILE = 'LICENSE'; + const RPATH_PATTERN = '/^b2\d+$/'; + private $jobTypes = array( 'B' => 'Backup', 'M' => 'Migrated', diff --git a/gui/baculum/protected/Pages/API/RestoreRun.php b/gui/baculum/protected/Pages/API/RestoreRun.php index 44d243a2e2..4599987210 100644 --- a/gui/baculum/protected/Pages/API/RestoreRun.php +++ b/gui/baculum/protected/Pages/API/RestoreRun.php @@ -33,13 +33,15 @@ class RestoreRun extends BaculumAPI { $replace = property_exists($params, 'replace') ? $params->replace : null; $client = $this->getModule('client')->getClientById($clientid); + $misc = $this->getModule('misc'); if(!is_null($fileset)) { if(!is_null($client)) { - if(preg_match('/^b2[\d]+$/', $rfile) === 1) { + if(preg_match($misc::RPATH_PATTERN, $rfile) === 1) { if(!is_null($where)) { if(!is_null($replace)) { $restore = $this->getModule('bconsole')->bconsoleCommand($this->director, array('restore', 'file="?' . $rfile . '"', 'client="' . $client->name . '"', 'where="' . $where . '"', 'replace="' . $replace . '"', 'fileset="' . $fileset . '"', 'priority="' . $priority . '"', 'yes'), $this->user); + $this->removeTmpRestoreTable($rfile); $this->output = $restore->output; $this->error = (integer)$restore->exitcode; } else { @@ -63,6 +65,19 @@ class RestoreRun extends BaculumAPI { $this->error = JobError::ERROR_FILESETID_DOES_NOT_EXISTS; } } + + private function removeTmpRestoreTable($tableName) { + $misc = $this->getModule('misc'); + if (preg_match($misc::RPATH_PATTERN, $tableName) === 1) { + $db = new ActiveRecord(); + $connection = $db->getDbConnection(); + $connection->setActive(true); + $sql = "DROP TABLE $tableName"; + $pdo = $connection->getPdoInstance(); + $pdo->exec($sql); + $pdo = null; + } + } } -?> \ No newline at end of file +?>