# HG changeset patch # User bears # Date 1003662012 -3600 # Node ID b9ef99708d1c144fc0ec4b86fc8358df3698a25a # Parent 28488e0e3630a39a10da5794e20eb90e0cbc5cd3 [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way. Auto-unsubscribe when the last access time is more than the threshold number of days behind the time the last article arrived. diff -r 28488e0e3630 -r b9ef99708d1c ChangeLog --- a/ChangeLog Sat Oct 20 14:23:46 2001 +0100 +++ b/ChangeLog Sun Oct 21 12:00:12 2001 +0100 @@ -1,3 +1,9 @@ +Sun Oct 21 2001 Jim Hague + +* docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way. + Auto-unsubscribe when the last access time is more than the threshold + number of days behind the time the last article arrived. + Sat Oct 20 2001 Jim Hague * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is diff -r 28488e0e3630 -r b9ef99708d1c docs/noffle.conf.5 --- a/docs/noffle.conf.5 Sat Oct 20 14:23:46 2001 +0100 +++ b/docs/noffle.conf.5 Sun Oct 21 12:00:12 2001 +0100 @@ -1,5 +1,5 @@ .TH noffle.conf 5 -.\" $Id: noffle.conf.5 300 2001-08-05 08:24:22Z bears $ +.\" $Id: noffle.conf.5 311 2001-10-21 11:00:12Z bears $ .SH NAME noffle.conf \- Configuration file for NOFFLE news server @@ -140,7 +140,8 @@ .TP .B auto-unsubscribe yes|no Automatically remove groups from fetch list if they have not been -accessed for a number days. +accessed for a number days. Groups are only unsubscribed if there +are fresh articles arriving and remaining unread. .br Default: no diff -r 28488e0e3630 -r b9ef99708d1c src/noffle.c --- a/src/noffle.c Sat Oct 20 14:23:46 2001 +0100 +++ b/src/noffle.c Sun Oct 21 12:00:12 2001 +0100 @@ -10,7 +10,7 @@ received for some seconds (to allow multiple clients connect at the same time). - $Id: noffle.c 310 2001-10-20 13:23:46Z bears $ + $Id: noffle.c 311 2001-10-21 11:00:12Z bears $ */ #if HAVE_CONFIG_H @@ -237,7 +237,7 @@ Str grp; Bool autoUnsubscribe; int autoUnsubscribeDays; - time_t now = time( NULL ), maxAge = 0; + time_t maxAge = 0; const char *msgId; autoUnsubscribe = Cfg_autoUnsubscribe(); @@ -267,30 +267,25 @@ else ++cntLeft; } + + /* + * Auto unsubscribe where applicable if last article arrival + * time is maxAge newer than the last access time. This ensures + * the low traffic groups don't get expired simply because + * there's been nothing to read. + */ if ( ! Grp_local( grp ) && Fetchlist_contains( grp ) && autoUnsubscribe - && difftime( now, Grp_lastAccess( grp ) ) > maxAge ) + && difftime( Grp_lastPostTime(grp), + Grp_lastAccess( grp ) ) > maxAge ) { - /* If there have been recent posts, unsubscribe. */ - if ( difftime( now, Grp_lastPostTime( grp ) ) <= maxAge ) - { - Log_ntc( "Auto-unsubscribing from %s after %d " - "days without access", - grp, autoUnsubscribeDays ); - Pseudo_autoUnsubscribed( grp, autoUnsubscribeDays ); - Fetchlist_remove( grp ); - Grp_setRmtNext( grp, GRP_RMT_NEXT_NOT_SUBSCRIBED ); - } - else - { - /* - * Otherwise if no recent posts touch the access. - * This way we don't unsubscribe to low volume groups - * unread only because there are no recent posts. - */ - Grp_setLastAccess( grp ); - } + Log_ntc( "Auto-unsubscribing from %s after %d " + "days without access", + grp, autoUnsubscribeDays ); + Pseudo_autoUnsubscribed( grp, autoUnsubscribeDays ); + Fetchlist_remove( grp ); + Grp_setRmtNext( grp, GRP_RMT_NEXT_NOT_SUBSCRIBED ); } Cont_write(); Grp_setFirstLast( grp, Cont_first(), Cont_last() );