33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2025-02-02 20:08:25 +00:00

Fix Backup not created when deleting files

This commit is contained in:
Nikolai Plath 2011-10-13 00:29:08 -05:00
parent edc9f41ff3
commit 5a4226413f

View File

@ -25,7 +25,7 @@ class PatchtesterModelPull extends JModel
protected function populateState() protected function populateState()
{ {
// Initialise variables. // Initialise variables.
$app = JFactory::getApplication('administrator'); // $app = JFactory::getApplication('administrator');
// Load the parameters. // Load the parameters.
$params = JComponentHelper::getParams('com_patchtester'); $params = JComponentHelper::getParams('com_patchtester');
@ -33,7 +33,7 @@ class PatchtesterModelPull extends JModel
$this->setState('github_user', $params->get('org')); $this->setState('github_user', $params->get('org'));
$this->setState('github_repo', $params->get('repo')); $this->setState('github_repo', $params->get('repo'));
parent::populateState(); // parent::populateState();
} }
@ -140,7 +140,7 @@ class PatchtesterModelPull extends JModel
foreach ($files AS $file) foreach ($files AS $file)
{ {
// we only create a backup if the file already exists // we only create a backup if the file already exists
if (file_exists(JPATH_ROOT . '/' . $file->new) && ($file->action == 'modified' || $file->action == 'deleted')) { if ($file->action == 'deleted' || (file_exists(JPATH_ROOT . '/' . $file->new) && $file->action == 'modified')) {
JFile::copy(JPath::clean(JPATH_ROOT . '/' . $file->old), JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'); JFile::copy(JPath::clean(JPATH_ROOT . '/' . $file->old), JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt');
} }