check daylight saving time offset when reading from database too.
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Fri, 9 Dec 2005 12:49:55 +0000 (12:49 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Fri, 9 Dec 2005 12:49:55 +0000 (12:49 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@246 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_updatedb

index 97811b8..233f4ee 100755 (executable)
@@ -16,6 +16,9 @@ use BackupPC::SearchLib;
 use constant BPC_FTYPE_DIR => 5;
 use constant EST_CHUNK => 100000;
 
+# daylight saving time change offset for 1h
+my $dst_offset = 60 * 60;
+
 my $debug = 0;
 $|=1;
 
@@ -50,9 +53,9 @@ my $dbh = DBI->connect($dsn, $user, "", { RaiseError => 1, AutoCommit => 0 });
 
 my %opt;
 
-if ( !getopts("cdm:v:ij", \%opt ) ) {
+if ( !getopts("cdm:v:ijf", \%opt ) ) {
        print STDERR <<EOF;
-usage: $0 [-c|-d] [-m num] [-v|-v level] [-i]
+usage: $0 [-c|-d] [-m num] [-v|-v level] [-i|-j|-f]
 
 Options:
        -c      create database on first use
@@ -61,10 +64,14 @@ Options:
        -v num  set verbosity (debug) level (default $debug)
        -i      update Hyper Estraier full text index
        -j      update full text, don't check existing files
+       -f      don't do anything with full text index
 
 Option -j is variation on -i. It will allow faster initial creation
 of full-text index from existing database.
 
+Option -f will create database which is out of sync with full text index. You
+will have to re-run $0 with -i to fix it.
+
 EOF
        exit 1;
 }
@@ -72,6 +79,9 @@ EOF
 if ($opt{v}) {
        print "Debug level at $opt{v}\n";
        $debug = $opt{v};
+} elsif ($opt{f}) {
+       print "WARNING: disabling full-text index update. You need to re-run $0 -j !\n";
+       ($use_hest, $index_path, $index_node_url) = (undef, undef, undef);
 }
 
 #---- subs ----
@@ -588,12 +598,12 @@ sub found_in_db {
                SELECT 1 FROM files
                WHERE shareID = ? and
                        path = ? and 
-                       date = ? and
-                       size = ?
+                       size = ? and
+                       ( date = ? or date = ? or date = ? )
                LIMIT 1
        });
 
-       my @param = ($shareID,$path,$date,$size);
+       my @param = ($shareID,$path,$size,$date, $date-$dst_offset, $date+$dst_offset);
        $sth->{file_in_db}->execute(@param);
        my $rows = $sth->{file_in_db}->rows;
        print STDERR "## found_in_db($shareID,$path,$date,$size) ",( $rows ? '+' : '-' ), join(" ",@param), "\n" if ($debug >= 3);
@@ -643,9 +653,6 @@ sub recurseDir($$$$$$$$) {
                                $filesInBackup->{$path_key}->{'size'}
                        ));
 
-                       # daylight saving time change offset for 1h
-                       my $dst_offset = 60 * 60;
-
                        my $key_dst_prev = join(" ", (
                                $shareID,
                                $dir,