]> git.donarmstrong.com Git - infobot.git/blobdiff - src/modules.pl
- patch from Morten Brix Pedersen:
[infobot.git] / src / modules.pl
index e0c881a3b8836df38bc9e73dd5c2db11cb0ea134..b5cadd76d24d719a396f9f6caf11cc7c3cdb0cf1 100644 (file)
@@ -76,7 +76,8 @@ sub loadCoreModules {
 sub loadDBModules {
     &status("Loading DB modules...");
 
-    $moduleAge{"$bot_src_dir/modules.pl"} = time();
+    my $f = "$bot_src_dir/modules.pl";
+    $moduleAge{$f} = (stat $f)[9];
 
     if ($param{'DBType'} =~ /^mysql$/i) {
        eval "use DBI";
@@ -87,20 +88,20 @@ sub loadDBModules {
        &showProc(" (DBI // mysql)");
 
        &status("  using MySQL support.");
-       require "$bot_src_dir/db_sql.pl";
-       require "$bot_src_dir/db_mysql.pl";
-       $moduleAge{"$bot_src_dir/db_mysql.pl"} = time();
+       $f = "$bot_src_dir/db_mysql.pl";
+       require $f;
+       $moduleAge{$f} = (stat $f)[9];
 
     } elsif ($param{'DBType'} =~ /^pgsql$/i) {
-       eval "use Pg";
+#      eval "use Pg";
+       eval "use DBI";
        if ($@) {
            &ERROR("libpgperl is not installed!");
            exit 1;
        }
-       &showProc(" (Pg // postgreSQLl)");
+       &showProc(" (pgsql)");
 
-       &status("  using PostgreSQL support.");
-       require "$bot_src_dir/db_sql.pl";
+       &status("  using pgsql support.");
        require "$bot_src_dir/db_pgsql.pl";
 
     } elsif ($param{'DBType'} =~ /^dbm$/i) {
@@ -248,7 +249,9 @@ sub reloadModule {
        return if ($age == $moduleAge{$file});
 
        if ($age < $moduleAge{$file}) {
-           &WARN("rM: we're not gonna downgrade the file. use 'touch'.");
+           &WARN("rM: we're not gonna downgrade '$file'; use touch.");
+           &DEBUG("age => $age");
+           &DEBUG("mA{$file} => $moduleAge{$file}");
            return;
        }
 
@@ -363,6 +366,10 @@ if ($@) {
 &showProc(" (Time::HiRes)");
 
 sub AUTOLOAD {
+    if (!defined $AUTOLOAD and defined $::AUTOLOAD) {
+       &DEBUG("AUTOLOAD: hrm.. ::AUTOLOAD defined!");
+    }
+    return unless (defined $AUTOLOAD);
     return if ($AUTOLOAD =~ /__/);     # internal.
 
     my $str = join(', ', @_);
@@ -381,7 +388,7 @@ sub getPerlFiles {
     my($dir) = @_;
 
     if (!opendir(DIR, $dir)) {
-        &ERROR("cannot open source directory $dir: $!");
+        &ERROR("Cannot open source directory ($dir): $!");
         exit 1;
     }