print STDERR " $tarfilename" if ($debug);
- my $path = "$tar_dir/$tarfilename";
- my $md5_path = $path;
- $md5_path =~ s/\.tar\.gz$/.md5/ || die "can't create md5 filename from $md5_path";
- if (! -e $md5_path || -z $md5_path) {
- print ", creating md5";
- system( $bin->{md5sum} . " $path > $md5_path") == 0 or die "can't create md5 $path: $!";
- }
-
- my $md5 = read_file( $md5_path ) || die "can't read md5sum file $md5_path: $!";
- $md5 =~ s#\s.*$##;
+ my $size = (stat( "$tar_dir/$tarfilename" ))[7] || die "can't stat $tar_dir/$tarfilename";
- my $part_nr = 1;
- $part_nr = $1 if ($tarfilename =~ m#/(\d+)\.tar\.gz#);
+ if ($size > $Conf{MaxArchiveSize}) {
+ print STDERR " part bigger than media $size > $Conf{MaxArchiveSize} }}" if ($debug);
+ $same = 0;
+ last;
+ }
- my $size = (stat( "$tar_dir/$tarfilename" ))[7] || die "can't stat $tar_dir/$tarfilename";
+ my $path = "$tar_dir/$tarfilename";
open(my $fh, "gzip -cd $tar_dir/$tarfilename |") or die "can't open $tar_dir/$tarfilename: $!";
binmode($fh);
push @tar_files, $entry->name;
$items++;
$tar_size += $entry->size;
+
+ if ($tar_size > $Conf{MaxArchiveFileSize}) {
+ print STDERR " part too big $tar_size > $Conf{MaxArchiveFileSize} }}" if ($debug);
+ $same = 0;
+ last;
+ }
+
}
- if ($tar_size > $Conf{MaxArchiveFileSize}) {
- print STDERR " part too big $tar_size > $Conf{MaxArchiveFileSize} }}" if ($debug);
- $same = 0;
- last;
- } elsif ($size > $Conf{MaxArchiveSize}) {
- print STDERR " part bigger than media $size > $Conf{MaxArchiveSize} }}" if ($debug);
- $same = 0;
- last;
+ #
+ # check if md5 exists, and if not, create one
+ #
+
+ my $md5_path = $path;
+ $md5_path =~ s/\.tar\.gz$/.md5/ || die "can't create md5 filename from $md5_path";
+ if (! -e $md5_path || -z $md5_path) {
+ print ", creating md5";
+ system( $bin->{md5sum} . " $path > $md5_path") == 0 or die "can't create md5 $path: $!";
}
+ my $md5 = read_file( $md5_path ) || die "can't read md5sum file $md5_path: $!";
+ $md5 =~ s#\s.*$##;
+
+ # extract part number from filename
+ my $part_nr = 1;
+ $part_nr = $1 if ($tarfilename =~ m#/(\d+)\.tar\.gz#);
+
+ #
+ # finally, check if backup_parts table in database is valid
+ #
+
check_part($host, $share, $num, $part_nr, $tar_size, $size, $md5, $items);
}