diff options
-rw-r--r-- | mbbsd/bbs.c | 4 | ||||
-rw-r--r-- | mbbsd/mail.c | 27 | ||||
-rw-r--r-- | mbbsd/read.c | 9 |
3 files changed, 29 insertions, 11 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 1b8a77ce..f2f48a05 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -1665,8 +1665,10 @@ del_range(int ent, fileheader_t *fhdr, char *direct) #endif fixkeep(direct, inum1); - if (currmode & MODE_BOARD) + if (currmode & MODE_BOARD) // Ptt:update cache setbtotal(currbid); + else if(currstat == RMAIL) + touchmailusage(); return DIRCHANGED; } diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 792dc976..015776e3 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -137,10 +137,15 @@ m_init() sethomedir(currmaildir, cuser.userid); } -int -chkmailbox() +void +touchmailusage() { - if (!HAVE_PERM(PERM_SYSOP) && !HAVE_PERM(PERM_MAILLIMIT)) { + mailkeep=0; +} + +void +setupmailusage() +{ // Ptt: get_sum_records is a bad function int max_keepmail = MAX_KEEPMAIL; if (HAS_PERM(PERM_SYSSUBOP) || HAS_PERM(PERM_SMG) || HAS_PERM(PERM_PRG) || HAS_PERM(PERM_ACTION) || HAS_PERM(PERM_PAINT)) { @@ -155,11 +160,18 @@ chkmailbox() mailsumlimit = 50; mailsumlimit += (cuser.exmailbox + ADD_EXMAILBOX) * 10; mailmaxkeep = max_keepmail + cuser.exmailbox; + mailkeep=get_num_records(currmaildir,sizeof(fileheader_t)); + mailsum =get_sum_records(currmaildir, sizeof(fileheader_t)); +} + +int +chkmailbox() +{ + if (!HAVE_PERM(PERM_SYSOP) && !HAVE_PERM(PERM_MAILLIMIT)) { + if(!mailkeep) setupmailusage(); m_init(); - if ((mailkeep = get_num_records(currmaildir, sizeof(fileheader_t))) > - mailmaxkeep || - (mailsum = get_sum_records(currmaildir, sizeof(fileheader_t))) > - mailsumlimit) { + if (mailkeep > mailmaxkeep || + mailsum > mailsumlimit) { bell(); bell(); vmsg("您保存信件數目或容量 %d 超出上限 %d, 請整理", @@ -829,6 +841,7 @@ mail_del(int ent, fileheader_t * fhdr, char *direct) if (getans(msg_del_ny) == 'y') { if (!delete_record(direct, sizeof(*fhdr), ent)) { + touchmailusage(); setdirpath(genbuf, direct, fhdr->filename); unlink(genbuf); return DIRCHANGED; diff --git a/mbbsd/read.c b/mbbsd/read.c index 53bc09ba..cb0d397c 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -177,6 +177,9 @@ TagPruner(int bid) TagNum = 0; if (bid) setbtotal(bid); + else if(currstat == RMAIL) + touchmailusage(); + return NEWDIRECT; } return DONOTHING; @@ -337,7 +340,7 @@ select_read(keeploc_t * locmem, int sr_mode) fileheader_t fhs[READSIZE]; char newdirect[MAXPATHLEN]; char keyword[TTLEN + 1] = ""; - char genbuf[MAXPATHLEN], *p = strstr(currdirect, "SR"); + char genbuf[MAXPATHLEN], *p = strstr(currdirect, "SR."); static int _mode = 0; int len, fd, fr, i, count=0, reference = 0; @@ -374,8 +377,8 @@ select_read(keeploc_t * locmem, int sr_mode) else _mode |= sr_mode; - snprintf(genbuf, sizeof(genbuf), "%s.%X.%X.%X", - p ? p : "SR", + snprintf(genbuf, sizeof(genbuf), "%s%X.%X.%X", + p ? p : "SR.", sr_mode, strlen(keyword), StringHash(keyword)); if( strlen(genbuf) > MAXPATHLEN - 50 ) return READ_REDRAW; // avoid overflow |