[spambayes-dev] Suggested patch for sb_mboxtrain.py 1.0a7

Shawn Dyer sdyer at dyermail.net
Wed Jan 28 22:31:49 EST 2004


When I ran sb_mboxtrain.py on my Maildir inbox, the timestamp on all of
the files was touched, which messed up the way Courier IMAP sorts by
receive date. Here is a suggested patch for sb_mboxtrain.py to preserve
the timestamps on the Maildir messages that it trains. It is a fairly
trivial patch. I now use it locally and can confirm that it preserves the
original modified time from the original email files when it adds the
trained header. The same technique would probably be useful for MHDir
messages, but I do not use that and so cannot test.

*** spambayes-1.0a7/scripts/sb_mboxtrain.py     Tue Nov  4 04:02:40 2003
--- ../spambayes-1.0a7/scripts/sb_mboxtrain.py  Mon Jan 26 00:53:02 2004
***************
*** 92,97 ****
--- 92,98 ----

      import time
      import socket
+     import shutil

      pid = os.getpid()
      host = socket.gethostname()
***************
*** 120,125 ****
--- 121,127 ----
          f = file(tfn, "wb")
          f.write(msg.as_string())
          f.close()
+         shutil.copystat(cfn,tfn)
          # XXX: This will raise an exception on Windows.  Do any Windows
          # people actually use Maildirs?
          os.rename(tfn, cfn)




More information about the spambayes-dev mailing list