[*] BO: More detailled errors when using Archive tar tool
This commit is contained in:
@@ -719,32 +719,36 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
@stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 5)))))
|
||||
{
|
||||
$file = _PS_TRANSLATIONS_DIR_.$arr_import_lang[0].'.gzip';
|
||||
if (file_put_contents($file, $content))
|
||||
if (is_writable(dirname($file)) && (bool)file_put_contents($file, $content))
|
||||
{
|
||||
$gz = new Archive_Tar($file, true);
|
||||
$files_list = $gz->listContent();
|
||||
if ($gz->extract(_PS_TRANSLATIONS_DIR_.'../', false))
|
||||
if ($error = $gz->extract(_PS_TRANSLATIONS_DIR_.'../', false))
|
||||
{
|
||||
AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list);
|
||||
$tab_errors = AdminTranslationsController::addNewTabs($arr_import_lang[0], $files_list);
|
||||
if (count($tab_errors))
|
||||
$this->errors += $tab_errors;
|
||||
if (is_object($error) && !empty($error->message))
|
||||
$this->errors[] = Tools::displayError('The archive cannot be extracted.'). ' '.$error->message;
|
||||
else
|
||||
{
|
||||
if (!Language::checkAndAddLanguage($arr_import_lang[0]))
|
||||
$conf = 20;
|
||||
AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list);
|
||||
$tab_errors = AdminTranslationsController::addNewTabs($arr_import_lang[0], $files_list);
|
||||
if (count($tab_errors))
|
||||
$this->errors += $tab_errors;
|
||||
else
|
||||
{
|
||||
if (!Language::checkAndAddLanguage($arr_import_lang[0]))
|
||||
$conf = 20;
|
||||
}
|
||||
if (!unlink($file))
|
||||
$this->errors[] = sprintf(Tools::displayError('Cannot delete the archive %s.'), $file);
|
||||
|
||||
$this->redirect(false, (isset($conf) ? $conf : '15'));
|
||||
}
|
||||
if (!unlink($file))
|
||||
$this->errors[] = Tools::displayError('Cannot delete the archive.');
|
||||
|
||||
$this->redirect(false, (isset($conf) ? $conf : '15'));
|
||||
}
|
||||
$this->errors[] = Tools::displayError('The archive cannot be extracted.');
|
||||
if (!unlink($file))
|
||||
$this->errors[] = Tools::displayError('Cannot delete the archive.');
|
||||
elseif (!unlink($file))
|
||||
$this->errors[] = sprintf(Tools::displayError('Cannot delete the archive %s.'), $file);
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('The server does not have permissions for writing.');
|
||||
$this->errors[] = Tools::displayError('The server does not have permissions for writing.'. ' '.sprintf(Tools::displayError('Please check rights for %s'), dirname($file)));
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('Language not found.');
|
||||
|
||||
+11
-12
@@ -441,7 +441,6 @@ class Archive_Tar extends PEAR
|
||||
"complete", 0, $p_remove_path, $check_base_dir);
|
||||
$this->_close();
|
||||
}
|
||||
|
||||
return $v_result;
|
||||
}
|
||||
// }}}
|
||||
@@ -568,7 +567,7 @@ class Archive_Tar extends PEAR
|
||||
function _error($p_message)
|
||||
{
|
||||
// ----- To be completed
|
||||
$this->raiseError($p_message);
|
||||
return $this->raiseError($p_message);
|
||||
}
|
||||
// }}}
|
||||
|
||||
@@ -576,7 +575,7 @@ class Archive_Tar extends PEAR
|
||||
function _warning($p_message)
|
||||
{
|
||||
// ----- To be completed
|
||||
$this->raiseError($p_message);
|
||||
return $this->raiseError($p_message);
|
||||
}
|
||||
// }}}
|
||||
|
||||
@@ -1327,7 +1326,7 @@ class Archive_Tar extends PEAR
|
||||
|
||||
if ($v_header['filename'] == $p_filename) {
|
||||
if ($v_header['typeflag'] == "5") {
|
||||
$this->_error('Unable to extract in string a directory '
|
||||
return $this->_error('Unable to extract in string a directory '
|
||||
.'entry {'.$v_header['filename'].'}');
|
||||
return NULL;
|
||||
} else {
|
||||
@@ -1386,7 +1385,7 @@ class Archive_Tar extends PEAR
|
||||
$v_listing = TRUE;
|
||||
break;
|
||||
default :
|
||||
$this->_error('Invalid extract mode ('.$p_mode.')');
|
||||
return $this->_error('Invalid extract mode ('.$p_mode.')');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1456,20 +1455,20 @@ class Archive_Tar extends PEAR
|
||||
if (file_exists($v_header['filename'])) {
|
||||
if ( (@is_dir($v_header['filename']))
|
||||
&& ($v_header['typeflag'] == '')) {
|
||||
$this->_error('File '.$v_header['filename']
|
||||
return $this->_error('File '.$v_header['filename']
|
||||
.' already exists as a directory');
|
||||
return false;
|
||||
}
|
||||
if ( ($this->_isArchive($v_header['filename']))
|
||||
&& ($v_header['typeflag'] == "5")) {
|
||||
$this->_error('Directory '.$v_header['filename']
|
||||
return $this->_error('Directory '.$v_header['filename']
|
||||
.' already exists as a file');
|
||||
return false;
|
||||
}
|
||||
if ($check_base_dir OR _PS_ROOT_DIR_ != realpath($v_header['filename']))
|
||||
{
|
||||
if (!is_writeable($v_header['filename'])) {
|
||||
$this->_error('File '.$v_header['filename']
|
||||
return $this->_error('File '.$v_header['filename']
|
||||
.' already exists and is write protected');
|
||||
return false;
|
||||
}
|
||||
@@ -1484,7 +1483,7 @@ class Archive_Tar extends PEAR
|
||||
= $this->_dirCheck(($v_header['typeflag'] == "5"
|
||||
?$v_header['filename']
|
||||
:dirname($v_header['filename'])))) != 1) {
|
||||
$this->_error('Unable to create path for '.$v_header['filename']);
|
||||
return $this->_error('Unable to create path for '.$v_header['filename']);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1492,14 +1491,14 @@ class Archive_Tar extends PEAR
|
||||
if ($v_header['typeflag'] == "5") {
|
||||
if (!@file_exists($v_header['filename'])) {
|
||||
if (!@mkdir($v_header['filename'], 0777)) {
|
||||
$this->_error('Unable to create directory {'
|
||||
return $this->_error('Unable to create directory {'
|
||||
.$v_header['filename'].'}');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) {
|
||||
$this->_error('Error while opening {'.$v_header['filename']
|
||||
return $this->_error('Error while opening {'.$v_header['filename']
|
||||
.'} in write binary mode');
|
||||
return false;
|
||||
} else {
|
||||
@@ -1524,7 +1523,7 @@ class Archive_Tar extends PEAR
|
||||
// ----- Check the file size
|
||||
clearstatcache();
|
||||
if (filesize($v_header['filename']) != $v_header['size']) {
|
||||
$this->_error('Extracted file '.$v_header['filename']
|
||||
return $this->_error('Extracted file '.$v_header['filename']
|
||||
.' does not have the correct file size \''
|
||||
.filesize($v_header['filename'])
|
||||
.'\' ('.$v_header['size']
|
||||
|
||||
Reference in New Issue
Block a user