From: NeilBrown Date: Mon, 16 Dec 2013 04:03:17 +0000 (+1100) Subject: storesms: purge old entries from newmesg and draft X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=2481b7b4fc24442b652352483f91731867124326;p=plato.git 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 --- 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):