Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve configuration getter for image backup #307

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AdminSelfUpgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function init()
$this->upgradeContainer->getFileConfigurationStorage()->cleanAll();
}

$this->keepImages = $this->upgradeContainer->getUpgradeConfiguration()->get('PS_AUTOUP_KEEP_IMAGES');
$this->keepImages = $this->upgradeContainer->getUpgradeConfiguration()->shouldBackupImages();
$this->updateDefaultTheme = $this->upgradeContainer->getUpgradeConfiguration()->get('PS_AUTOUP_UPDATE_DEFAULT_THEME');
$this->changeToDefaultTheme = $this->upgradeContainer->getUpgradeConfiguration()->get('PS_AUTOUP_CHANGE_DEFAULT_THEME');
$this->keepMails = $this->upgradeContainer->getUpgradeConfiguration()->get('PS_AUTOUP_KEEP_MAILS');
Expand Down
8 changes: 8 additions & 0 deletions classes/Parameters/UpgradeConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ public function getPerformanceLevel()
return $this->get('PS_AUTOUP_PERFORMANCE') - 1;
}

/**
* @return bool True if the autoupgrade module should backup the images as well
*/
public function shouldBackupImages()
{
return (bool) $this->get('PS_AUTOUP_KEEP_IMAGES');
}

/**
* @return bool True if non-native modules must be disabled during upgrade
*/
Expand Down
2 changes: 1 addition & 1 deletion classes/Parameters/UpgradeConfigurationStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getDefaultData()
'PS_AUTOUP_CHANGE_DEFAULT_THEME' => 0,
'PS_AUTOUP_KEEP_MAILS' => 0,
'PS_AUTOUP_BACKUP' => 1,
'PS_AUTOUP_KEEP_IMAGES' => 0,
'PS_AUTOUP_KEEP_IMAGES' => 1,
'channel' => Upgrader::DEFAULT_CHANNEL,
'archive.filename' => Upgrader::DEFAULT_FILENAME,
);
Expand Down
2 changes: 2 additions & 0 deletions classes/TaskRunner/Upgrade/UpgradeComplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ public function run()

// Reinit config
Configuration::deleteByName('PS_AUTOUP_IGNORE_REQS');
// removing temporary files
$this->container->getFileConfigurationStorage()->cleanAll();
}
}
4 changes: 2 additions & 2 deletions classes/UpgradeTools/FileFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getFilesToIgnoreOnBackup()
'/admin/autoupgrade',
);

if ($this->configuration->get('PS_AUTOUP_KEEP_IMAGES') === '0') {
if (!$this->configuration->shouldBackupImages()) {
$backupIgnoreAbsoluteFiles[] = '/img';
} else {
$backupIgnoreAbsoluteFiles[] = '/img/tmp';
Expand All @@ -92,7 +92,7 @@ public function getFilesToIgnoreOnRestore()
'..',
);

if ($this->configuration->get('PS_AUTOUP_KEEP_IMAGES') === '0') {
if (!$this->configuration->shouldBackupImages()) {
$restoreIgnoreAbsoluteFiles[] = '/img';
} else {
$restoreIgnoreAbsoluteFiles[] = '/img/tmp';
Expand Down