/[BackupPC]/trunk/bin/BackupPC_incPartsUpdate
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/BackupPC_incPartsUpdate

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 214 by dpavlin, Sun Oct 16 12:33:05 2005 UTC revision 218 by dpavlin, Sun Oct 16 17:48:05 2005 UTC
# Line 13  use POSIX qw/strftime/; Line 13  use POSIX qw/strftime/;
13  use BackupPC::SearchLib;  use BackupPC::SearchLib;
14  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
15  use File::Which;  use File::Which;
16  use Archive::Tar;  use Archive::Tar::Streamed;
17  use Algorithm::Diff;  use Algorithm::Diff;
18  use Getopt::Std;  use Getopt::Std;
19    
20    # cludge: minimum .tar.gz size
21    my $MIN_TAR_SIZE = 80;
22    
23  my $path = abs_path($0);  my $path = abs_path($0);
24  $path =~ s#/[^/]+$#/#;  $path =~ s#/[^/]+$#/#;
25  my $tarIncCreate = $path .= 'BackupPC_tarIncCreate';  my $tarIncCreate = $path .= 'BackupPC_tarIncCreate';
# Line 95  sub tar_check($$$$) { Line 98  sub tar_check($$$$) {
98                  tar_join($filename);                  tar_join($filename);
99          }          }
100    
         my $tar = Archive::Tar->new;  
         my $comp = 0;  
         $comp = 1 if ($filename =~ m/\.(gz|tgz)$/);  
101          print STDERR ", opening" if ($debug);          print STDERR ", opening" if ($debug);
102          $tar->read($filename, $comp) or die "can't open $filename: $!";          open(my $fh, "gzip -cd $filename |") or die "can't open $filename: $!";
103            binmode($fh);
104            my $tar = Archive::Tar::Streamed->new($fh);
105    
106          print STDERR ", tar" if ($debug);          print STDERR ", tar" if ($debug);
107          my @tar_files = sort $tar->list_files();          my @tar_files;
108            while(my $entry = $tar->next) {
109                    push @tar_files, $entry->name;
110            }
111            @tar_files = sort @tar_files;
112          print STDERR " ",($#tar_files + 1), " files" if ($debug);          print STDERR " ",($#tar_files + 1), " files" if ($debug);
113    
114          print STDERR ", database" if ($debug);          print STDERR ", database" if ($debug);
# Line 142  sub tar_check($$$$) { Line 148  sub tar_check($$$$) {
148                  }                  }
149          }          }
150    
151          print STDERR " ",($same ? 'ok' : 'DIFFERENT');          print " ",($same ? 'ok' : 'DIFFERENT');
152          print STDERR " }} " if ($debug);          print STDERR " }} " if ($debug);
153    
154          return $same;          return $same;
# Line 204  while (my $row = $sth->fetchrow_hashref) Line 210  while (my $row = $sth->fetchrow_hashref)
210                  $size = (stat( "$tar_dir/$tar_file" ))[7];                  $size = (stat( "$tar_dir/$tar_file" ))[7];
211          }          }
212    
213          if ($size > 45) {          if ($size > $MIN_TAR_SIZE) {
214    
215                  my $max_size = $Conf{'MaxArchiveSize'} || die "problem with MaxArchieSize parametar";                  my $max_size = $Conf{'MaxArchiveSize'} || die "problem with MaxArchieSize parametar";
216                  $max_size *= 1024;      # convert to bytes                  $max_size *= 1024;      # convert to bytes

Legend:
Removed from v.214  
changed lines
  Added in v.218

  ViewVC Help
Powered by ViewVC 1.1.26