Skip to content

Commit

Permalink
Improve configuration getter for image backup
Browse files Browse the repository at this point in the history
  • Loading branch information
Quetzacoalt91 committed May 3, 2019
1 parent e50f680 commit fafc475
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
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->upgradeContainer->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

0 comments on commit fafc475

Please sign in to comment.