Die if disk full.
This commit is contained in:
parent
719cc67c25
commit
a8634adc3b
6
Notes
6
Notes
|
@ -63,3 +63,9 @@ Tape performance:
|
||||||
|
|
||||||
Equality checking doesn't work for setuid files.
|
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
|
||||||
|
|
|
@ -119,7 +119,8 @@ sub backup2disk {
|
||||||
my $header = <$file_dfd>; # this should be the same as $_ - check?
|
my $header = <$file_dfd>; # this should be the same as $_ - check?
|
||||||
if ($header =~ /^data (.*)/) {
|
if ($header =~ /^data (.*)/) {
|
||||||
my $f2 = $self->parse($1);
|
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 $size = $f2->{s};
|
||||||
my $err;
|
my $err;
|
||||||
my $sha1 = Digest::SHA1->new;
|
my $sha1 = Digest::SHA1->new;
|
||||||
|
@ -136,11 +137,11 @@ sub backup2disk {
|
||||||
$self->log(5, "unexpected EOF reading from data socket");
|
$self->log(5, "unexpected EOF reading from data socket");
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
$file_bfd->print($buffer);
|
$file_bfd->print($buffer) or die "write to backup failed: $!";
|
||||||
$size -= length($buffer);
|
$size -= length($buffer);
|
||||||
$sha1->add($buffer);
|
$sha1->add($buffer);
|
||||||
}
|
}
|
||||||
close($file_bfd);
|
close($file_bfd) or die "write to backup failed: $!";
|
||||||
my $trailer = <$file_dfd>; # should be empty line
|
my $trailer = <$file_dfd>; # should be empty line
|
||||||
$trailer = <$file_dfd>;
|
$trailer = <$file_dfd>;
|
||||||
if ($trailer =~ /^fail /) {
|
if ($trailer =~ /^fail /) {
|
||||||
|
@ -347,7 +348,8 @@ sub name2gid {
|
||||||
sub log {
|
sub log {
|
||||||
my ($self, $level, $msg) = @_;
|
my ($self, $level, $msg) = @_;
|
||||||
if ($level <= $self->{log_level}) {
|
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_owner, file_group, file_acl,
|
||||||
file_unix_bits,
|
file_unix_bits,
|
||||||
file_rdev,
|
file_rdev,
|
||||||
date, checksum, online, file_linktarget)
|
date, checksum, online, file_linktarget,
|
||||||
|
session)
|
||||||
values(?,
|
values(?,
|
||||||
?, ?, ?, ?,
|
?, ?, ?, ?,
|
||||||
?, ?, ?,
|
?, ?, ?,
|
||||||
|
@ -398,7 +401,7 @@ sub db_record_version {
|
||||||
|
|
||||||
sub new_session {
|
sub new_session {
|
||||||
my ($self) = @_;
|
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'};
|
$self->{session_id} = $self->{dbh}->{'mysql_insertid'};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,7 +284,8 @@ sub no_such_command {
|
||||||
sub log {
|
sub log {
|
||||||
my ($self, $level, $msg) = @_;
|
my ($self, $level, $msg) = @_;
|
||||||
if ($level <= $self->{log_level}) {
|
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: $!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue