[configfiles] don't mv a file that is to be backed up but has mode=append, use cp instead

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2015-09-08 08:18:32 +02:00
parent 1d3ae4f2c8
commit afbfb810fd

View File

@@ -297,7 +297,12 @@ class ConfigDaemon {
// @TODO: Maybe have a backup - location somewhere central?
// @TODO: Use IO - class
if (array_key_exists('backup', $attributes)) {
$return[] = array('type' => 'command', 'content' => 'mv "' . $this->_parseContent($attributes['name']) . '" "' . $this->_parseContent($attributes['name']) . '.frx.bak"', 'execute' => "pre");
if (array_key_exists('mode', $attributes) && $attributes['mode'] == 'append') {
$cmd = 'cp';
} else {
$cmd = 'mv';
}
$return[] = array('type' => 'command', 'content' => $cmd.' "' . $this->_parseContent($attributes['name']) . '" "' . $this->_parseContent($attributes['name']) . '.frx.bak"', 'execute' => "pre");
}
// Now the content of the file can be written