--- trunk/bin/BackupPC_updatedb 2005/08/30 09:55:34 95 +++ trunk/bin/BackupPC_updatedb 2005/08/30 09:55:55 97 @@ -13,6 +13,7 @@ use POSIX qw/strftime/; use constant BPC_FTYPE_DIR => 5; +use constant EST_SYNC_EVERY => 10000; my $debug = 0; $|=1; @@ -85,6 +86,19 @@ my $hest_db; +sub signal { + my($sig) = @_; + if ($hest_db) { + print "\nCaught a SIG$sig--syncing database and shutting down\n"; + $hest_db->sync(); + $hest_db->close(); + } + exit(0); +} + +$SIG{'INT'} = \&signal; +$SIG{'QUIT'} = \&signal; + sub hest_update { my ($host_id, $share_id, $num) = @_; @@ -197,6 +211,11 @@ $max--; } + if ($added % EST_SYNC_EVERY == 0) { + print "sync "; + $db->sync(); + } + } print "sync $added new files";