record sessions.

This commit is contained in:
hjp 2007-06-18 20:11:27 +00:00
parent f186cd0c94
commit 719cc67c25
1 changed files with 17 additions and 5 deletions

View File

@ -83,6 +83,7 @@ sub backup2disk {
my $timestamp = $self->{timestamp} || strftime('%Y-%m-%dT%H.%M.%S', localtime);
$self->{this_backup} = $self->{basedir} . "/$timestamp/" . $target->{host} . '/' . $target->{dir};
$self->new_session();
my ($list_pid, $list_cfd, $list_dfd); # connection to get list of files
my ($file_pid, $file_cfd, $file_dfd); # connection to get content of files
@ -178,6 +179,7 @@ sub backup2disk {
# insert into DB.
$self->db_record_version($target, $f);
}
$self->close_session();
}
sub parse {
@ -381,19 +383,29 @@ sub db_record_version {
?, ?, ?,
?,
?,
?, ?, ?, ?)",
?, ?, ?, ?,
?)",
{},
$db_f->[0]{id},
$f->{id}, $f->{t}, $f->{s}, $f->{m},
$f->{o}, $f->{g}, $f->{acl},
join(',', map {$f->{$_} ? ($_) : ()} qw(setuid setgid sticky)),
$f->{rdev},
time(),
$f->{checksum},
1,
$f->{lt}
time(), $f->{checksum}, 1, $f->{lt},
$self->{session_id}
);
}
sub new_session {
my ($self) = @_;
$self->{dbh}->do("insert into sessions(start_date, prefix)", {}, time(), $self->{this_backup});
$self->{session_id} = $self->{dbh}->{'mysql_insertid'};
}
sub close_session {
my ($self) = @_;
$self->{dbh}->do("update sessions set end_date=? where id=?", {}, time(), $self->{session_id});
}
# vim: tw=0 expandtab
1;