summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2019-02-15 07:36:13 +0000
committerintrigeri <intrigeri@boum.org>2019-02-15 07:36:13 +0000
commitd40f7cdec4d75f7c0d0eb0cbd6d1eff7b3f14227 (patch)
treea0746fb5baa9da9b0895258f37f03d66241382bd
parent85e56d07b8eab9b1b79338547284b16471193c06 (diff)
Refactoring: extract common code to method.
-rw-r--r--lib/Tails/Persistence/Configuration/ConfigFile.pm14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Tails/Persistence/Configuration/ConfigFile.pm b/lib/Tails/Persistence/Configuration/ConfigFile.pm
index 27237f7..b911b4a 100644
--- a/lib/Tails/Persistence/Configuration/ConfigFile.pm
+++ b/lib/Tails/Persistence/Configuration/ConfigFile.pm
@@ -77,6 +77,16 @@ method output () {
return $out;
}
+=head2 backup
+
+Copy the on-disk configuration file to a backup file.
+
+=cut
+
+method backup () {
+ $self->config_file_path->copy($self->config_file_path . '.bak');
+}
+
=head2 save
Save the in-memory configuration to disk.
@@ -86,7 +96,7 @@ Throw exception on error.
method save () {
my $config_file_was_empty = ! -s $self->config_file_path;
unless ($config_file_was_empty) {
- $self->config_file_path->copy($self->config_file_path . '.bak');
+ $self->backup;
}
$self->config_file_path->spew($self->output);
$self->config_file_path->chmod(0600);
@@ -99,7 +109,7 @@ method save () {
# we're initializing a new persistent volume), let's backup the
# (probably non-empty) version of it that we've just saved.
if ($config_file_was_empty) {
- $self->config_file_path->copy($self->config_file_path . '.bak');
+ $self->backup;
}
}