From eefec1d45b4122c94629ab55d39d4bdf5f7dec43 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sun, 17 Jan 2010 15:07:08 +0100 Subject: [PATCH] Fix some problems with config/database reloading --- lib/Packages/Config.pm | 6 +++--- lib/Packages/DB.pm | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/Packages/Config.pm b/lib/Packages/Config.pm index 2ec87ed..a7014f8 100644 --- a/lib/Packages/Config.pm +++ b/lib/Packages/Config.pm @@ -24,7 +24,7 @@ sub init { my ($dir) = @_; my $modtime = (stat( "$dir/config.sh" ))[9] || 0; $config_read_time ||= 0; - if ($modtime >= $config_read_time) { + if ($modtime > $config_read_time) { if (!open (C, '<', "$dir/config.sh")) { error( "Internal: Cannot open configuration file." ); } @@ -50,12 +50,12 @@ sub init { s/\$\{?topdir\}?/$TOPDIR/g; } close (C); + unshift @LANGUAGES, 'en'; + unshift @DDTP_LANGUAGES, 'en'; debug( "read config ($modtime > $config_read_time)" ) if DEBUG; $config_read_time = $modtime; } $DBDIR = "$TOPDIR/files/db"; - unshift @LANGUAGES, 'en'; - unshift @DDTP_LANGUAGES, 'en'; } 1; diff --git a/lib/Packages/DB.pm b/lib/Packages/DB.pm index 1402690..e6d1b3f 100644 --- a/lib/Packages/DB.pm +++ b/lib/Packages/DB.pm @@ -19,31 +19,44 @@ our $db_read_time ||= 0; sub init { my $dbmodtime = (stat("$DBDIR/packages_small.db"))[9] || 0; - if ($dbmodtime >= $db_read_time) { + if ($dbmodtime > $db_read_time) { + undef $obj; + untie %packages; $obj = tie %packages, 'DB_File', "$DBDIR/packages_small.db", O_RDONLY, 0666, $DB_BTREE or die "couldn't tie DB $DBDIR/packages_small.db: $!"; + undef $s_obj; + untie %sources; $s_obj = tie %sources, 'DB_File', "$DBDIR/sources_small.db", O_RDONLY, 0666, $DB_BTREE or die "couldn't tie DB $DBDIR/sources_small.db: $!"; + untie %src2bin; tie %src2bin, 'DB_File', "$DBDIR/sources_packages.db", O_RDONLY, 0666, $DB_BTREE or die "couldn't open $DBDIR/sources_packages.db: $!"; + untie %descriptions; tie %descriptions, 'DB_File', "$DBDIR/descriptions.db", O_RDONLY, 0666, $DB_BTREE or die "couldn't tie DB $DBDIR/descriptions.db: $!"; + untie %desctrans; tie %desctrans, 'DB_File', "$DBDIR/descriptions_translated.db", O_RDONLY, 0666, $DB_BTREE or die "couldn't tie DB $DBDIR/descriptions_translated.db: $!"; + untie %did2pkg; tie %did2pkg, 'DB_File', "$DBDIR/descriptions_packages.db", O_RDONLY, 0666, $DB_BTREE or die "couldn't tie DB $DBDIR/descriptions_packages.db: $!"; + untie %debtags; tie %debtags, 'DB_File', "$TOPDIR/files/debtags/vocabulary.db", O_RDONLY, 0666, $DB_BTREE or die "couldn't tie DB $TOPDIR/files/debtags/vocabulary.db: $!"; + undef $p_obj; + untie %postf; $p_obj = tie %postf, 'DB_File', "$DBDIR/package_postfixes.db", O_RDONLY, 0666, $DB_BTREE or die "couldn't tie postfix db $DBDIR/package_postfixes.db: $!"; + undef $sp_obj; + untie %spostf; $sp_obj = tie %spostf, 'DB_File', "$DBDIR/source_postfixes.db", O_RDONLY, 0666, $DB_BTREE or die "couldn't tie postfix db $DBDIR/source_postfixes.db: $!"; -- 2.39.2