From d43e298db7037bd83ab368b5392412d965eebcc7 Mon Sep 17 00:00:00 2001 From: dms Date: Sat, 7 Apr 2001 12:07:38 +0000 Subject: [PATCH] - now backup news file just in case. - Other changes we've not documented or small enough not to mention git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@434 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/IRC/Schedulers.pl | 38 +++++++++++++++++++++----------------- src/modules.pl | 3 +-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index 1bdba62..0f28ddc 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -722,23 +722,10 @@ sub miscCheck { } closedir DEBIAN; - # user/chan file check. - foreach ("chan","users") { - my $f = $bot_misc_dir."/blootbot.$_"; - my $backup = 0; - - if ( -e "$f~" ) { - $backup++ if ( -s $f > -s "$f~"); - $backup++ if ( (stat $f)[9] - (stat "$f~")[9] > 60*60*24*7); - } else { - $backup++; - } - next unless ($backup); - - ### TODO: do internal copying. - &status("Backup: $f to $f~"); - CORE::system("/bin/cp $f $f~"); - } + # make backup of important files. + &mkBackup( $bot_misc_dir."/blootbot.chan", 60*60*24*1); + &mkBackup( $bot_misc_dir."/blootbot.users", 60*60*24*1); + &mkBackup( $bot_base_dir."/blootbot-news.txt", 60*60*24*1); # flush cache{lobotomy} foreach (keys %{ $cache{lobotomy} }) { @@ -1080,4 +1067,21 @@ sub getChanConfDefault { return $default; } +sub mkBackup { + my($file, $time) = @_; + my $backup = 0; + + if ( -e "$file~" ) { + $backup++ if ( -s $file > -s "$file~"); + $backup++ if ( (stat $file)[9] - (stat "$file~")[9] > $time); + } else { + $backup++; + } + return unless ($backup); + + ### TODO: do internal copying. + &status("Backup: $file to $file~"); + CORE::system("/bin/cp $file $file~"); +} + 1; diff --git a/src/modules.pl b/src/modules.pl index ee86c38..791bd9f 100644 --- a/src/modules.pl +++ b/src/modules.pl @@ -193,9 +193,8 @@ sub loadMyModulesNow { } if (!&IsParam($_) and !&IsChanConf($_) and !&getChanConfList($_)) { - &DEBUG("_ => $_"); if (exists $myModules{$_}) { - &status("myModule: $myModules{$_} (1) not loaded."); + &status("myModule: $myModules{$_} or $_ (1) not loaded."); } else { &DEBUG("myModule: $_ (2) not loaded."); } -- 2.39.5