]> git.neil.brown.name Git - plato.git/commitdiff
storesms: purge old entries from newmesg and draft
authorNeilBrown <neilb@suse.de>
Mon, 16 Dec 2013 04:03:17 +0000 (15:03 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 16 Dec 2013 04:04:25 +0000 (15:04 +1100)
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

index ea757292ea2208a8435bdf9a7d4cbc8935e472d6..477786423e17747c8a8fdc211db896b5da5378ea 100644 (file)
@@ -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):