Script to convert spool directory to "basic hashing"
brong at fastmail.fm
Mon Oct 15 06:15:03 EDT 2007
On Mon, 15 Oct 2007 11:49:33 +0200, "Sascha Wilde" <wilde at intevation.de> said:
> "Bron Gondwana" <brong at fastmail.fm> writes:
> > There's a much more complete re-implementation of the rehash script
> > available as part of:
> > http://cyrus.brong.fastmail.fm/patches/cyrus-hashuser-2.3.9.diff
> > which also has another hashing style which groups folders by the user
> > who owns them all at one level, basically to make fastrename a lot
> > cleaner.
> Thanks for the link, looks interesting on a quick glance. Being a
> part of a patch, which changes the spool layout, is your 'rehash'
> still capable of converting to classic "basic" hashing?
> That is, from:
It's capable of converting from any of the current hashing methods plus
our new one to any of the others. That means yes :)
It unwinds and rewinds the directories so that you never move something
that may contain a subdirectory - necessary for our format where folders
aren't subfolders of anything - everything is just hashed to a toplevel
of that user's username. It means some things wind up in a temp directory
for a bit, but that's OK because it's capable of resuming from said
temp directory if anything gets delayed.
The way it works is basically:
a) parse the directory tree looking for directories are mailboxes (or
the equivalent meta/sieve/quota items)
b) parse the name to canonicalise it as a username or full mailbox path.
c) use the converter function for the target hashing style to convert
back to the new path.
d) if they are different, move it!
This generalises linearly to multiple formats, whereas the old-style
rehash had to map from every possible to every other possible explicitly
which had two downsides:
1) you had to know your current format. This script doesn't care - every
format is distinct enough that you can calculate the correct name for
the mailbox that a directory maps to.
2) you couldn't re-run it quite so easily as it would get confused by the
This script can be run over and over again - after the first run it should
find nothing that needs moving any more!
Bron ( it could probably do with some independent testing of course )
brong at fastmail.fm
More information about the Cyrus-devel