mailbox.mbox.add() sets access time as well as modification time

Grant Edwards grante at visi.com
Mon Apr 27 05:23:35 CEST 2009


On 2009-04-26, tinnews at isbd.co.uk <tinnews at isbd.co.uk> wrote:
> Grant Edwards <invalid at invalid> wrote:
>> > I suppose I could do the following:-
>> >
>> >     lock the mbox
>> >     get the atime
>> >     add the new message with mailbox.mbox.add()
>> >     restore the atime
>> >     unlock the mbox
>> 
>> You could fix mbox.add().  ;)
>> 
> Yes, but I'm not sure that I'm that competant!

I bet you are -- it's Python, not C++.  [1]

 * You understand the problem: both how the current version
   works and how it should work.

 * You know how to test for the problem.    

That's the hard part.

The rest is just typing.  And dealing with bugtracking systems
(personally, I find that to be the most difficult part).
Actually, just entering the bug along with a small demo app
showing the problem is probably all you really need to do. I'm
sure the library maintainers would appreciate a patch as well,
but if they're anything like me, me they apprecate a demo app
and test cases a lot more.

>>> All I need to do now is find out how to get and set atime with
>>> python.
>> 
>> You use os.utime().
>
> Thanks!

My apologies: I forgot to tell you how to _get_ atime and
mtime, but I see somebody else already has.  There is one
tricky bit (as explained on a qmail man page).  If the file was
last read less that a second before the message was added, you
could end up with the case where atime==mtail (they only have
1-second granularity).  Apparently there are MUAs that think
that means "no new mail", so qmail's delivery code checks for
that case and sets atime = mtime-1.

[1] Admit it, you thought I couldn't work a shot at C++ into
    this thread...

-- 
Grant




More information about the Python-list mailing list