From 4dfa80ce75869d391591a813638195b23674dc6b Mon Sep 17 00:00:00 2001 From: Hector Cortez Date: Fri, 3 Aug 2012 18:00:50 -0400 Subject: [PATCH] BUG 9443 In Centos 5.4 Is not possible to do the restore a backup file SOLVED - In Centos 5.4 is not possible to restore a backup file of ProcessMaker. we are using the next command. - Adjustment in the restore backup, in the erased the hidden files. --- gulliver/system/class.g.php | 15 +++++++++++---- workflow/engine/classes/class.wsTools.php | 16 +++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index b75c0edef..fd5e5ce02 100755 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -563,14 +563,21 @@ class G } if (is_dir($dirName)) { - foreach(glob($dirName . '/*') as $file) { + foreach(glob($dirName . '/{,.}*', GLOB_BRACE) as $file) { + if ( $file == $dirName . '/.' || $file == $dirName . '/..') { + continue; + } if(is_dir($file)) { G::rm_dir($file); - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') - exec('DEL /F /S /Q %' . $dirName . '%', $res); - else + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $dirNameWin = str_replace('/','\\' ,$dirName); + exec('DEL /F /S /Q ' . $dirNameWin . '', $res); + exec('RD /S /Q ' . $dirNameWin . '', $res); + } else { @rmdir($file); + } + } else { @unlink($file); diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index 20b214e84..1c89da681 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -968,10 +968,16 @@ class workspaceTools { $backup = new Archive_Tar($filename); //Get a temporary directory in the upgrade directory $tempDirectory = PATH_DATA . "upgrade/" . basename(tempnam(__FILE__, '')); - mkdir($tempDirectory); + $parentDirectory = PATH_DATA . "upgrade"; + if (is_writable($parentDirectory)) { + mkdir($tempDirectory); + } else { + throw new Exception("Could not create directory:" . $parentDirectory); + } //Extract all backup files, including database scripts and workspace files - if (!$backup->extract($tempDirectory)) - throw new Exception("Could not extract backup"); + if (!$backup->extract($tempDirectory)) { + throw new Exception("Could not extract backup"); + } //Search for metafiles in the new standard (the old standard would contain //txt files). $metaFiles = glob($tempDirectory . "/*.meta"); @@ -1015,9 +1021,9 @@ class workspaceTools { else throw new Exception("Destination workspace already exist (use -o to overwrite)"); - if (file_exists($workspace->path)) + if (file_exists($workspace->path)) { G::rm_dir($workspace->path); - + } foreach ($metadata->directories as $dir) { CLI::logging("+> Restoring directory '$dir'\n");