summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-04-01 20:23:16 +0200
committerFlorian Pritz <bluewind@xinu.at>2017-04-01 20:23:16 +0200
commitb83c55e97fa95713f66198c42577c284036ecefa (patch)
tree589346f372d83ada4d56e278292a4d708e0e1e65
parent4d1540fe2acabc69ff5426e28a3b45762318de5d (diff)
downloadApp-BorgRestore-b83c55e97fa95713f66198c42577c284036ecefa.tar.gz
App-BorgRestore-b83c55e97fa95713f66198c42577c284036ecefa.tar.xz
Do not pass $opts to main class
The only reason this was done, was for the debug output. This no longer requires large amounts of memory or time (simple count(*) in the db now) so this is no longer necessary. Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--lib/App/BorgRestore.pm8
-rw-r--r--t/02_parsing.t2
-rw-r--r--t/03_timespec.t2
-rw-r--r--t/04_find_archives.t2
4 files changed, 4 insertions, 10 deletions
diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm
index abff5e1..7fa3251 100644
--- a/lib/App/BorgRestore.pm
+++ b/lib/App/BorgRestore.pm
@@ -64,7 +64,6 @@ Florian Pritz E<lt>bluewind@xinu.atE<gt>
sub new {
my $class = shift;
- my $opts = shift;
my $deps = shift;
my $self = {};
@@ -73,7 +72,6 @@ sub new {
my $db_path = App::BorgRestore::Settings::get_cache_path('archives.db');
# TODO: make db_path configurable, probably settings too
- $self->{opts} = $opts;
$self->{borg} = $deps->{borg} // App::BorgRestore::Borg->new();
$self->{db} = $deps->{db} // App::BorgRestore::DB->new($db_path);
@@ -82,13 +80,11 @@ sub new {
sub new_no_defaults {
my $class = shift;
- my $opts = shift;
my $deps = shift;
my $self = {};
bless $self, $class;
- $self->{opts} = $opts;
$self->{borg} = $deps->{borg};
$self->{db} = $deps->{db};
@@ -352,9 +348,7 @@ sub build_archive_cache {
$self->handle_removed_archives($borg_archives);
$self->handle_added_archives($borg_archives);
- if ($self->{opts}->{debug}) {
- $log->debugf("DB contains information for %d archives in %d rows", scalar(@{$self->{db}->get_archive_names()}), $self->{db}->get_archive_row_count());
- }
+ $log->debugf("DB contains information for %d archives in %d rows", scalar(@{$self->{db}->get_archive_names()}), $self->{db}->get_archive_row_count());
}
sub save_node {
diff --git a/t/02_parsing.t b/t/02_parsing.t
index 9ff0a5c..8f3bcfb 100644
--- a/t/02_parsing.t
+++ b/t/02_parsing.t
@@ -27,7 +27,7 @@ $borg->mock('list_archive', sub {
} );
# Call the actual function we want to test
-my $app = App::BorgRestore->new({}, {borg => $borg, db => $db});
+my $app = App::BorgRestore->new({borg => $borg, db => $db});
$app->handle_added_archives(['archive-1'], $db);
# Check if $db->add_path has been called properly
diff --git a/t/03_timespec.t b/t/03_timespec.t
index 250ce9f..ae1b1e5 100644
--- a/t/03_timespec.t
+++ b/t/03_timespec.t
@@ -5,7 +5,7 @@ use Test::More;
use App::BorgRestore;
-my $app = App::BorgRestore->new_no_defaults({}, undef);
+my $app = App::BorgRestore->new_no_defaults(undef);
is($app->timespec_to_seconds('5s'), 5, '5 seconds');
is($app->timespec_to_seconds('5minutes'), 5*60, '5 minutes');
diff --git a/t/04_find_archives.t b/t/04_find_archives.t
index 2d40eef..7f0186a 100644
--- a/t/04_find_archives.t
+++ b/t/04_find_archives.t
@@ -17,7 +17,7 @@ $db->mock('get_archives_for_path', sub {return [
{ modification_time => 15, archive => "test5"},
];});
-my $app = App::BorgRestore->new_no_defaults({}, {db => $db});
+my $app = App::BorgRestore->new_no_defaults({db => $db});
eq_or_diff($app->find_archives('test/path'), [
{archive => 'test1', modification_time => 2},