From: Marcin Haba Date: Sat, 12 Dec 2015 19:39:56 +0000 (+0100) Subject: baculum: Fix restore when a lot of jobids given X-Git-Tag: Release-7.4.0~142 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e99c370aa0fb9b1df11fa48e9c3d5844d92f25c8;p=bacula%2Fbacula baculum: Fix restore when a lot of jobids given --- diff --git a/gui/baculum/protected/Class/Errors.php b/gui/baculum/protected/Class/Errors.php index 410a3ca878..559760ad93 100644 --- a/gui/baculum/protected/Class/Errors.php +++ b/gui/baculum/protected/Class/Errors.php @@ -110,9 +110,11 @@ class FileSetError extends GenericError { class BVFSError extends GenericError { const ERROR_JOB_DOES_NOT_EXISTS = 70; - const ERROR_INVALID_PATH = 71; + const ERROR_INVALID_RPATH = 71; + const ERROR_INVALID_RESTORE_PATH = 72; const MSG_ERROR_JOB_DOES_NOT_EXISTS = 'Job with inputed jobid does not exist.'; - const MSG_ERROR_INVALID_PATH = 'Inputed path for restore is invalid. Proper format is b2[0-9]+.'; + const MSG_ERROR_INVALID_RPATH = 'Inputed path for restore is invalid. Proper format is b2[0-9]+.'; + const MSG_ERROR_INVALID_RESTORE_PATH = 'Inputted BVFS path param is invalid.'; } ?> diff --git a/gui/baculum/protected/Pages/API/BVFSLsDirs.php b/gui/baculum/protected/Pages/API/BVFSLsDirs.php index d409644b52..8661712567 100644 --- a/gui/baculum/protected/Pages/API/BVFSLsDirs.php +++ b/gui/baculum/protected/Pages/API/BVFSLsDirs.php @@ -22,33 +22,47 @@ class BVFSLsDirs extends BaculumAPI { - public function get() { - $ids = $this->Request['id']; - $path = $this->Request['path']; + public function get() {} + + public function set($param, $ids) { $limit = intval($this->Request['limit']); $offset = intval($this->Request['offset']); - $jobids = explode(',', $ids); $isValid = true; - for($i = 0; $i < count($jobids); $i++) { - $job = $this->getModule('job')->getJobById($jobids[$i]); - if(is_null($job)) { - $isValid = false; - break; + if (property_exists($ids, 'jobids')) { + $jobids = explode(',', $ids->jobids); + for($i = 0; $i < count($jobids); $i++) { + $job = $this->getModule('job')->getJobById($jobids[$i]); + if(is_null($job)) { + $isValid = false; + break; + } } + } else { + $isValid = false; + } + + $path = null; + if (property_exists($ids, 'path')) { + $path = $ids->path; } if($isValid === true) { - $cmd = array('.bvfs_lsdirs', 'jobid="' . $ids . '"', 'path="' . $path . '"'); - - if($offset > 0) { - array_push($cmd, 'offset="' . $offset . '"'); - } - if($limit > 0) { - array_push($cmd, 'limit="' . $limit . '"'); + if (!is_null($path)) { + $cmd = array('.bvfs_lsdirs', 'jobid="' . $ids->jobids . '"', 'path="' . $path . '"'); + + if($offset > 0) { + array_push($cmd, 'offset="' . $offset . '"'); + } + if($limit > 0) { + array_push($cmd, 'limit="' . $limit . '"'); + } + $result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd, $this->user); + $this->output = $result->output; + $this->error = (integer)$result->exitcode; + } else { + $this->output = BVFSError::ERROR_INVALID_RESTORE_PATH; + $this->error = BVFSError::MSG_ERROR_INVALID_RESTORE_PATH; } - $result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd, $this->user); - $this->output = $result->output; - $this->error = (integer)$result->exitcode; } else { $this->output = BVFSError::MSG_ERROR_JOB_DOES_NOT_EXISTS; $this->error = BVFSError::ERROR_JOB_DOES_NOT_EXISTS; diff --git a/gui/baculum/protected/Pages/API/BVFSLsFiles.php b/gui/baculum/protected/Pages/API/BVFSLsFiles.php index d13f054ab0..a91223c545 100644 --- a/gui/baculum/protected/Pages/API/BVFSLsFiles.php +++ b/gui/baculum/protected/Pages/API/BVFSLsFiles.php @@ -22,32 +22,46 @@ class BVFSLsFiles extends BaculumAPI { - public function get() { - $ids = $this->Request['id']; - $path = $this->Request['path']; + public function get() {} + + public function set($param, $ids) { $limit = intval($this->Request['limit']); $offset = intval($this->Request['offset']); - $jobids = explode(',', $ids); $isValid = true; - for($i = 0; $i < count($jobids); $i++) { - $job = $this->getModule('job')->getJobById($jobids[$i]); - if(is_null($job)) { - $isValid = false; - break; + if (property_exists($ids, 'jobids')) { + $jobids = explode(',', $ids->jobids); + for($i = 0; $i < count($jobids); $i++) { + $job = $this->getModule('job')->getJobById($jobids[$i]); + if(is_null($job)) { + $isValid = false; + break; + } } + } else { + $isValid = false; + } + + $path = null; + if (property_exists($ids, 'path')) { + $path = $ids->path; } - + if($isValid === true) { - $cmd = array('.bvfs_lsfiles', 'jobid="' . $ids . '"', 'path="' . $path . '"'); - if($offset > 0) { - array_push($cmd, 'offset="' . $offset . '"'); - } - if($limit > 0) { - array_push($cmd, 'limit="' . $limit . '"'); + if (!is_null($path)) { + $cmd = array('.bvfs_lsfiles', 'jobid="' . $ids->jobids . '"', 'path="' . $path . '"'); + if($offset > 0) { + array_push($cmd, 'offset="' . $offset . '"'); + } + if($limit > 0) { + array_push($cmd, 'limit="' . $limit . '"'); + } + $result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd, $this->user); + $this->output = $result->output; + $this->error = (integer)$result->exitcode; + } else { + $this->output = BVFSError::ERROR_INVALID_RESTORE_PATH; + $this->error = BVFSError::MSG_ERROR_INVALID_RESTORE_PATH; } - $result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd, $this->user); - $this->output = $result->output; - $this->error = (integer)$result->exitcode; } else { $this->output = BVFSError::MSG_ERROR_JOB_DOES_NOT_EXISTS; $this->error = BVFSError::ERROR_JOB_DOES_NOT_EXISTS; diff --git a/gui/baculum/protected/Pages/API/BVFSRestore.php b/gui/baculum/protected/Pages/API/BVFSRestore.php index ab8e00ad37..085d6dc412 100644 --- a/gui/baculum/protected/Pages/API/BVFSRestore.php +++ b/gui/baculum/protected/Pages/API/BVFSRestore.php @@ -57,8 +57,8 @@ class BVFSRestore extends BaculumAPI { $this->output = $result->output; $this->error = (integer)$result->exitcode; } else { - $this->output = BVFSError::MSG_ERROR_INVALID_PATH; - $this->error = BVFSError::ERROR_INVALID_PATH; + $this->output = BVFSError::MSG_ERROR_INVALID_RPATH; + $this->error = BVFSError::ERROR_INVALID_RPATH; } } else { $this->output = BVFSError::MSG_ERROR_JOB_DOES_NOT_EXISTS; diff --git a/gui/baculum/protected/Pages/API/BVFSUpdate.php b/gui/baculum/protected/Pages/API/BVFSUpdate.php index 3d52251280..15b7c382f9 100644 --- a/gui/baculum/protected/Pages/API/BVFSUpdate.php +++ b/gui/baculum/protected/Pages/API/BVFSUpdate.php @@ -24,19 +24,23 @@ class BVFSUpdate extends BaculumAPI { public function get() {} - public function set($ids, $params) { - $jobids = explode(',', $ids); + public function set($param, $ids) { $isValid = true; - for($i = 0; $i < count($jobids); $i++) { - $job = $this->getModule('job')->getJobById($jobids[$i]); - if(is_null($job)) { - $isValid = false; - break; + if (property_exists($ids, 'jobids')) { + $jobids = explode(',', $ids->jobids); + for($i = 0; $i < count($jobids); $i++) { + $job = $this->getModule('job')->getJobById($jobids[$i]); + if(is_null($job)) { + $isValid = false; + break; + } } + } else { + $isValid = false; } if($isValid === true) { - $result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.bvfs_update', 'jobid="' . $ids . '"'), $this->user); + $result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.bvfs_update', 'jobid="' . $ids->jobids . '"'), $this->user); $this->output = $result->output; $this->error = (integer)$result->exitcode; } else { diff --git a/gui/baculum/protected/Pages/RestoreWizard.php b/gui/baculum/protected/Pages/RestoreWizard.php index 761a2257c5..67e7ddcd44 100644 --- a/gui/baculum/protected/Pages/RestoreWizard.php +++ b/gui/baculum/protected/Pages/RestoreWizard.php @@ -295,10 +295,10 @@ class RestoreWizard extends BaculumPage // generating Bvfs may takes a moment $this->generateBvfsCacheByJobids($jobids); - $bvfsDirsList = $this->getModule('api')->get(array('bvfs', 'lsdirs', $jobids, '?path=' . urlencode($this->getBrowserPath(true)) . '')); + $bvfsDirsList = $this->getModule('api')->set(array('bvfs', 'lsdirs'), array('jobids' => $jobids, 'path' => $this->getBrowserPath(true))); $bvfsDirs = is_object($bvfsDirsList) ? $bvfsDirsList->output : array(); $dirs = $this->getModule('misc')->parseBvfsList($bvfsDirs); - $bvfsFilesList = $this->getModule('api')->get(array('bvfs', 'lsfiles', $jobids, '?path=' . urlencode($this->getBrowserPath(true)) . '')); + $bvfsFilesList = $this->getModule('api')->set(array('bvfs', 'lsfiles'), array('jobids' => $jobids, 'path' => $this->getBrowserPath(true))); $bvfsFiles = is_object($bvfsFilesList) ? $bvfsFilesList->output : array(); $files = $this->getModule('misc')->parseBvfsList($bvfsFiles); $elements = array_merge($dirs, $files); @@ -332,7 +332,7 @@ class RestoreWizard extends BaculumPage } private function generateBvfsCacheByJobids($jobids) { - $this->getModule('api')->set(array('bvfs', 'update', $jobids), array()); + $this->getModule('api')->set(array('bvfs', 'update'), array('jobids' => $jobids)); } private function setFileVersions($versions) { diff --git a/gui/baculum/protected/application.xml b/gui/baculum/protected/application.xml index ad0e839f0d..2ec14fe6cf 100644 --- a/gui/baculum/protected/application.xml +++ b/gui/baculum/protected/application.xml @@ -69,13 +69,13 @@ - - - - - - - + + + + + + +