Bug#354307: packages.qa.debian.org/m/mydsn.html has weird sorted news
On Sat, 26 Jan 2008, Stefano Zacchiroli wrote:
> On Sat, Jan 26, 2008 at 02:17:19PM +0100, Raphael Hertzog wrote:
> > Note that this behaviour should be fixed. It happens that dak send several
> > Accepted mails during the same second for example when the package gets
> > out of NEW and when several upload happened while the package was sitting
> > in NEW.
> >
> > I remember neuro complaining about getting bounces on those cases. Jeroen
> > never got around to fix that.
>
> Ok, here is a proposed (yet untested) fix:
>
> zack@aquarium:/srv/debian/pts/www/bin$ svn diff common.py
> Index: common.py
> ===================================================================
> --- common.py (revision 1821)
> +++ common.py (working copy)
> @@ -18,8 +18,13 @@
> info = extract_info(msg)
>
> targetfile = "%s/%s.txt" % (dir, info['timestamp'])
targetfile = "%s/%s.0.txt" % (dir, info['timestamp'])
At least it'll fix the sorting order...
> - if os.path.isfile(targetfile):
> - raise("Aiee, already such message %s" % targetfile)
> + nonce = 0
> + while os.path.isfile(targetfile):
> + nonce += 1
> + if nonce > 128: # eventually give up
> + raise("can't find a free slot to save message, last stried was %s"\
s/stried/tried/
> + % targetfile)
> + targetfile = "%s/%s.%d.txt" % (dir, info['timestamp'], nonce)
> f = open(targetfile, "w")
> f.write(msg.as_string())
> f.close()
>
> It assumes however that all mails received in the very same second are
> to be kept, is it a correct assumption?
I think so.
> Also, it sort strangely news received in the very same second, here is
> an example of what I mean (ipython session):
>
> In [18]: a=['1236.txt', '1235.txt', '1234.txt', '1235.1.txt', '1235.2.txt']
> In [19]: a.sort()
> In [20]: a.reverse()
> In [21]: a
> Out[21]: ['1236.txt', '1235.txt', '1235.2.txt', '1235.1.txt', '1234.txt']
>
> This can be fixed in update_news.py using an ad-hoc sorting function,
> but I don't think it's worth, after all those mail have all been
> received in the very same second, whatever order would do IMO.
You can also simply fix the default filename. :)
> Let me know if you want me to commit this fix or not ...
Go ahead with the little changes above.
Cheers,
--
Raphaël Hertzog
Le best-seller français mis à jour pour Debian Etch :
http://www.ouaza.com/livre/admin-debian/
Reply to: