diff --git a/Notes b/Notes index 316bb30..206dd9f 100644 --- a/Notes +++ b/Notes @@ -63,3 +63,9 @@ Tape performance: Equality checking doesn't work for setuid files. +Implement equality checking via saved checksum. + +checksum is null if file is linked. Is that ok? Can this be solved +together with the previous point? + +exit if disk full diff --git a/lib/Simba/CA.pm b/lib/Simba/CA.pm index ff967d2..d3809b4 100644 --- a/lib/Simba/CA.pm +++ b/lib/Simba/CA.pm @@ -119,7 +119,8 @@ sub backup2disk { my $header = <$file_dfd>; # this should be the same as $_ - check? if ($header =~ /^data (.*)/) { my $f2 = $self->parse($1); - open(my $file_bfd, '>:raw', "$self->{this_backup}/$f->{name}") or die; # XXX + my $backup_filename = "$self->{this_backup}/$f->{name}"; + open(my $file_bfd, '>:raw', $backup_filename) or die "cannot open backup file $backup_filename: $!"; my $size = $f2->{s}; my $err; my $sha1 = Digest::SHA1->new; @@ -136,11 +137,11 @@ sub backup2disk { $self->log(5, "unexpected EOF reading from data socket"); last; } - $file_bfd->print($buffer); + $file_bfd->print($buffer) or die "write to backup failed: $!"; $size -= length($buffer); $sha1->add($buffer); } - close($file_bfd); + close($file_bfd) or die "write to backup failed: $!"; my $trailer = <$file_dfd>; # should be empty line $trailer = <$file_dfd>; if ($trailer =~ /^fail /) { @@ -347,7 +348,8 @@ sub name2gid { sub log { my ($self, $level, $msg) = @_; if ($level <= $self->{log_level}) { - $self->{fh_log}->print(strftime("%Y-%m-%dT%H:%M:%S%z", localtime), " $$ [$level]: $msg\n"); + $self->{fh_log}->print(strftime("%Y-%m-%dT%H:%M:%S%z", localtime), " $$ [$level]: $msg\n") + or die "write to log failed: $!"; } } @@ -377,7 +379,8 @@ sub db_record_version { file_owner, file_group, file_acl, file_unix_bits, file_rdev, - date, checksum, online, file_linktarget) + date, checksum, online, file_linktarget, + session) values(?, ?, ?, ?, ?, ?, ?, ?, @@ -398,7 +401,7 @@ sub db_record_version { sub new_session { my ($self) = @_; - $self->{dbh}->do("insert into sessions(start_date, prefix)", {}, time(), $self->{this_backup}); + $self->{dbh}->do("insert into sessions(start_date, prefix) values(?, ?)", {}, time(), $self->{this_backup}); $self->{session_id} = $self->{dbh}->{'mysql_insertid'}; } diff --git a/lib/Simba/DA.pm b/lib/Simba/DA.pm index 04efe2e..e31cf49 100644 --- a/lib/Simba/DA.pm +++ b/lib/Simba/DA.pm @@ -284,7 +284,8 @@ sub no_such_command { sub log { my ($self, $level, $msg) = @_; if ($level <= $self->{log_level}) { - $self->{fh_log}->print(strftime("%Y-%m-%dT%H:%M:%S%z", localtime), " $$ [$level]: $msg\n"); + $self->{fh_log}->print(strftime("%Y-%m-%dT%H:%M:%S%z", localtime), " $$ [$level]: $msg\n") + or die "write to log failed: $!"; } }