From b8c2d709664900b09f849e8b5e1afada0be580df Mon Sep 17 00:00:00 2001 From: dms Date: Sun, 23 Feb 2003 18:28:03 +0000 Subject: [PATCH] On Sun, Feb 23, 2003 at 10:55:55AM -0700, Tim Riker wrote: > I would like HUP to re-read the chan/user files if the dates have > changed, and write them if it has not. so you can: > > HUP > edit > HUP - now possible. git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@769 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/Misc.pl | 16 ++++++++++++++++ src/core.pl | 9 +++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Misc.pl b/src/Misc.pl index 1965db2..76f11eb 100644 --- a/src/Misc.pl +++ b/src/Misc.pl @@ -470,6 +470,22 @@ sub isStale { return 0; } +sub isFileUpdated { + my ($file, $time) = @_; + + if (! -f $file) { + return 1; + } + + my $time_file = (stat $file)[9]; + + if ($time == $time_file) { + return 0; + } else { + return 1; + } +} + ########## ### make commands. ### diff --git a/src/core.pl b/src/core.pl index 4c5d0e7..c82c47e 100644 --- a/src/core.pl +++ b/src/core.pl @@ -493,10 +493,11 @@ sub shutdown { $ident ||= "blootbot"; # hack. - if ($sig eq "HUP") { - &status("::: not writing user/chan file w/ SIGHUP"); - } else { - &writeUserFile(); + if (!&isFileUpdated("$bot_state_dir/blootbot.users", $wtime_userfile)) { + &writeUserFile() + } + + if (!&isFileUpdated("$bot_state_dir/blootbot.chan", $wtime_chanfile)) { &writeChanFile(); } -- 2.39.2