From 2481b7b4fc24442b652352483f91731867124326 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 16 Dec 2013 15:03:17 +1100 Subject: [PATCH] storesms: purge old entries from newmesg and draft If there is no message, discard the record. This means the if newmesg is not empty, then there really are new messages --- sms/storesms.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sms/storesms.py b/sms/storesms.py index ea75729..4777864 100644 --- a/sms/storesms.py +++ b/sms/storesms.py @@ -1,6 +1,5 @@ # # FIXME -# - trim newmesg and draft when possible. # - remove old multipart files # # Store SMS messages is a bunch of files, one per month. @@ -396,6 +395,15 @@ class SMSstore: if s: s.state = state rv.append(s) + elif state == 'NEW' or state == 'DRAFT': + def del1(l, tm): + if tm in l: + l.remove(tm) + return True + return False + self.load_list('draft', del1, t) + self.load_list('newmesg', del1, t) + return(0, rv) def getmesgs(self, last): -- 2.39.5