added $debug level to make script chatty to STDERR
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Sun, 31 Jul 2005 15:59:19 +0000 (15:59 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Sun, 31 Jul 2005 15:59:19 +0000 (15:59 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@30 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_updatedb

index 2584789..de75414 100755 (executable)
@@ -9,6 +9,7 @@ use Data::Dumper;
 use Getopt::Std;
 use constant BPC_FTYPE_DIR => 5;
 
+my $debug = 0;
 $|=1;
 
 my $hosts;
@@ -272,7 +273,7 @@ sub recurseDir($$$$$$$$) {
 
        my ($bpc, $hostname, $backups, $backupNum, $share, $dir, $shareID) = @_;
 
-#print STDERR "recurse($hostname,$backupNum,$share,$dir,$shareID)\n";
+       print STDERR "recurse($hostname,$backupNum,$share,$dir,$shareID)\n" if ($debug >= 1);
 
        my ($nr_files, $new_files, $nr_dirs, $new_dirs) = (0,0,0,0);
 
@@ -306,14 +307,14 @@ sub recurseDir($$$$$$$$) {
 
 
                        if (! $beenThere->{$key} && ! found_in_db(@data)) {
-##print STDERR "# key: $key [", $beenThere->{$key},"]";
+                               print STDERR "# key: $key [", $beenThere->{$key},"]" if ($debug >= 2);
                                $sth->{'insert_files'}->execute(@data);
                                if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {
                                        $new_dirs++;
-##print STDERR " dir\n";
+                                       print STDERR " dir\n" if ($debug >= 2);
                                } else {
                                        $new_files++;
-##print STDERR " file\n";
+                                       print STDERR " file\n" if ($debug >= 2);
                                }
                        }
                        $beenThere->{$key}++;
@@ -323,7 +324,7 @@ sub recurseDir($$$$$$$$) {
 
                                my $full_path = $dir . '/' . $path_key;
                                push @stack, $full_path;
-##print STDERR "### store to stack: $full_path\n";
+                               print STDERR "### store to stack: $full_path\n" if ($debug >= 3);
 
 #                              my ($f,$nf,$d,$nd) = recurseDir($bpc, $hostname, $backups, $backupNum, $share, $path_key, $shareID) unless ($beenThere->{$key});
 #
@@ -337,11 +338,11 @@ sub recurseDir($$$$$$$$) {
                        }
                }
 
-##print STDERR "# STACK ",join(", ", @stack),"\n";
+               print STDERR "## STACK ",join(", ", @stack),"\n" if ($debug >= 2);
 
                while ( my $dir = shift @stack ) {
                        my ($f,$nf,$d,$nd) = recurseDir($bpc, $hostname, $backups, $backupNum, $share, $dir, $shareID);
-#      print STDERR "## $dir f: $f nf: $nf d: $d nd: $nd\n";
+                       print STDERR "# $dir f: $f nf: $nf d: $d nd: $nd\n" if ($debug >= 1);
                        $nr_files += $f;
                        $new_files += $nf;
                        $nr_dirs += $d;