[-] BO: Don't delete the directory of modules before upgrade them
This commit is contained in:
@@ -600,25 +600,14 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
foreach ($modules as $name)
|
foreach ($modules as $name)
|
||||||
{
|
{
|
||||||
$full_report = null;
|
$full_report = null;
|
||||||
if ($key == 'update')
|
|
||||||
{
|
|
||||||
if (ConfigurationTest::test_dir('modules/'.$name, true, $full_report))
|
|
||||||
Tools::deleteDirectory('../modules/'.$name.'/');
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$module = Module::getInstanceByName(urldecode($name));
|
|
||||||
$this->errors[] = $this->l(sprintf("Module %s can't be upgraded : ", $module->displayName)).$full_report;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If Addons module, download and unzip it before installing it
|
// If Addons module, download and unzip it before installing it
|
||||||
if (!file_exists('../modules/'.$name.'/'.$name.'.php'))
|
if (!file_exists('../modules/'.$name.'/'.$name.'.php') || $key == 'update')
|
||||||
{
|
{
|
||||||
$filesList = array(
|
$filesList = array(
|
||||||
array('type' => 'addonsNative', 'file' => Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0),
|
array('type' => 'addonsNative', 'file' => Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0),
|
||||||
array('type' => 'addonsBought', 'file' => Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1),
|
array('type' => 'addonsBought', 'file' => Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1),
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($filesList as $f)
|
foreach ($filesList as $f)
|
||||||
if (file_exists(_PS_ROOT_DIR_.$f['file']))
|
if (file_exists(_PS_ROOT_DIR_.$f['file']))
|
||||||
{
|
{
|
||||||
@@ -628,12 +617,19 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
foreach ($xml->module as $modaddons)
|
foreach ($xml->module as $modaddons)
|
||||||
if ($name == $modaddons->name && isset($modaddons->id) && ($this->logged_on_addons || $f['loggedOnAddons'] == 0))
|
if ($name == $modaddons->name && isset($modaddons->id) && ($this->logged_on_addons || $f['loggedOnAddons'] == 0))
|
||||||
{
|
{
|
||||||
|
$download_ok = false;
|
||||||
if ($f['loggedOnAddons'] == 0)
|
if ($f['loggedOnAddons'] == 0)
|
||||||
if (file_put_contents('../modules/'.$modaddons->name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id)))))
|
if (file_put_contents(_PS_MODULE_DIR_.$modaddons->name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id)))))
|
||||||
$this->extractArchive('../modules/'.$modaddons->name.'.zip', false);
|
$download_ok = true;
|
||||||
if ($f['loggedOnAddons'] == 1 && $this->logged_on_addons)
|
elseif ($f['loggedOnAddons'] == 1 && $this->logged_on_addons)
|
||||||
if (file_put_contents('../modules/'.$modaddons->name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons))))))
|
if (file_put_contents(_PS_MODULE_DIR_.$modaddons->name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons))))))
|
||||||
$this->extractArchive('../modules/'.$modaddons->name.'.zip', false);
|
$download_ok = true;
|
||||||
|
|
||||||
|
if (!$download_ok)
|
||||||
|
$this->errors[] = $this->l('Error on downloading the lastest version');
|
||||||
|
else
|
||||||
|
if(!$this->extractArchive(_PS_MODULE_DIR_.$modaddons->name.'.zip', false))
|
||||||
|
$this->errors[] = $this->l(sprintf("Module %s can't be upgraded: ", $module->displayName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user