Closed command file handle after list to force DA to exit.

Restructured code in present to find bug (bug vanished, but I don't see
why).
Made mkdir_p a little bit more fault tolerant.
This commit is contained in:
hjp 2006-11-20 09:03:25 +00:00
parent ee8667368f
commit 533b2bf32e
1 changed files with 12 additions and 5 deletions

View File

@ -10,6 +10,8 @@ use Simba::Util qw(quote unquote typestr);
use Readonly;
use Digest::SHA1;
use List::Util qw(min);
use IO::Handle;
use File::stat;
Readonly my $BUFSIZE => 128 * 1024;
@ -53,6 +55,7 @@ sub backup2disk {
my ($file_pid, $file_cfd, $file_dfd); # connection to get content of files
$list_pid = open2($list_dfd, $list_cfd, "/usr/bin/ssh", "-l", "simba_da", $target->{host}, "da");
$list_cfd->printflush("list $target->{dir}\n"); # XXX - encode!
close($list_cfd);
while (<$list_dfd>) {
# split into fields
my $f = $self->parse($_);
@ -139,10 +142,10 @@ sub parse {
sub present {
my ($self, $f) = @_;
my $st;
if ($self->{last_backup} &&
($st = lstat("$self->{last_backup}/$f->{name}")) &&
$st->mtime == $f->{m} &&
return unless $self->{last_backup};
my $st = lstat("$self->{last_backup}/$f->{name}");
return unless $st;
if ($st->mtime == $f->{m} &&
$st->size == $f->{s} &&
uid2name($st->uid) eq $f->{o} &&
uid2name($st->gid) eq $f->{g} &&
@ -169,7 +172,11 @@ sub mkdir_p {
my $parentdir = $dir;
$parentdir =~ s|(.*)/.+|$1|;
mkdir_p($parentdir, $perm);
return mkdir($dir, $perm);
if (-d $dir) {
return 1;
} else {
return mkdir($dir, $perm);
}
} else {
return undef;
}