SimpleBackuper/RestoreDB.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 33 CC 6 SCAR 34.7
CC
6
Cov
0%
RestoreDB
42.0
BEGIN
2.0
BEGIN
2.0
CRAP 32.0
1 package App::SimpleBackuper;
2  
3 use strict;
4 use warnings;
5  
6 sub RestoreDB {
7 my($options, $state) = @_;
8
9 my $db_file = App::SimpleBackuper::RegularFile->new($options->{db}, $options);
10 print "Downloading database file from storage.\n" if ! $options->{quiet};
11
12 $db_file->data_ref(\$state->{storage}->get('db')->[0]);
13
14 print "Downloading database keys from storage.\n" if ! $options->{quiet};
15 my $db_key = $state->{storage}->get('db.key')->[0];
16
17 print "Decrypting database keys with RSA private key.\n" if ! $options->{quiet};
18 $db_key = $state->{rsa}->decrypt($db_key);
19 my($key, $iv) = unpack("a32a16", $db_key);
20
21 print "Decrypting database with AES database keys.\n" if ! $options->{quiet};
22 $db_file->decrypt($key, $iv);
23
24 print "Saving database.\n" if ! $options->{quiet};
25 $db_file->write();
26 }
27  
28 1;