]> git.deb.at Git - deb/packages.git/blobdiff - lib/Packages/DB.pm
Improve error handling:
[deb/packages.git] / lib / Packages / DB.pm
index e959f60298182b33c722bd5bf1af680f64fae538..6d5db6295e5b550589724ed58831e72d1d7a94d7 100644 (file)
@@ -18,8 +18,8 @@ our @EXPORT = qw( %packages %sources %src2bin %did2pkg %descriptions
 our $db_read_time ||= 0;
 
 sub init {
-    my $dbmodtime = (stat("$DBDIR/packages_small.db"))[9];
-    if ($dbmodtime > $db_read_time) {
+    my $dbmodtime = (stat("$DBDIR/packages_small.db"))[9] || 0;
+    if ($dbmodtime >= $db_read_time) {
        $obj = tie %packages, 'DB_File', "$DBDIR/packages_small.db",
        O_RDONLY, 0666, $DB_BTREE
            or die "couldn't tie DB $DBDIR/packages_small.db: $!";
@@ -42,7 +42,7 @@ sub init {
        O_RDONLY, 0666, $DB_BTREE
            or die "couldn't tie postfix db $DBDIR/source_postfixes.db: $!";
 
-       debug( "tied databases ($dbmodtime > $db_read_time)" );
+       debug( "tied databases ($dbmodtime > $db_read_time)" ) if DEBUG;
        $db_read_time = $dbmodtime;
     }
 }