Re: copying and renaming mailboxes to clean up directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2 May 2007, Thorsten Büker wrote:

I bet the problem is that on a large mailbox, $imap->messages will return a really big list of UIDs (longer than the allowed MAXWORD of 32768). You may be able to fix this by calling "$imap->Ranges(1);" earlier in the script. According to the Mail::IMAPClient docs, with that enabled it will try to generate a condensed list of UIDs when possible.

Yes, it works fine. In case somebody likes to test, I added "$imap1->Ranges(1);" to line 90.

Great, I added that to my local copy.

Did you set "allowusermoves: 1" in imapd.conf?

I did, but it shows no effect. Indeed "man imapd.conf" doesn't list this option -- is it already implemented in "2.1.18-1+sarge2"?

Hmm, I'm using v2.2.13 here. Maybe that option/feature didn't exist in 2.1.x.

If I understand you correctly, you want to get a list of "valid" UIDs from the folder listing, and then delete (from the filesystem) anything which is not in that list of "valid" UIDs?

Or do you intend to just copy the mailbox to a new mailbox, delete the old mailbox, and copy it back? That sounds pretty reasonable to me. One problem you might have is the loss of the seen state for each mailbox because the mailbox unique ID will change with the copy. The unique ID is stored in the cyrus.header file in each mailbox/folder, so you might be able to save those and copy them back as you go.

I just hat some tries on the latter way.

Beside the seen state the subscription list of a user needs to be transferred in some way. Manually duplicating thorsten.sub to thorsten_neu.sub (overwritten file of copied mailbox) and modifiying the file lead to a restore of subscription on the new (temporary) mailbox. But, as you already assumed, the seen state gets lost...

Is there anything else in addition to the seen state and subscriptions, which needs to be kept?

You should probably check if other message flags (Important, Answered, etc) are copied. I can't remember.

Furthermore I must admit, that I wasn't aware right now, that by copying a mailbox the name/number of a mail in the filesystem changes, too. I just had the idea to copy a mailbox, execute "find" in both directories, "diff" the differences and create some kind of remove loop on filesystem level outside of Cyrus. But oviously this stays an idea :-/

Is this name/number the key, which you are refering to by "mailbox unique ID"?

Have a look at any cyrus.header file and you'll see something like:

----------------------------------
Cyrus mailbox header
"The best thing about this system was that it had lots of goals."
        --Jim Morris on Andrew
user.morgan     3e671c013f511626
morgan  lrswipcda
----------------------------------

The string "3e671c013f511626" is the unique mailbox ID for this particular mailbox. It is the key value used in the seen files to track which message UIDs have been seen for each mailbox.

Another attempt:
Are there any reasons, why something like

ORIG=`grep -R -e '^Message-ID:' $originalmbox | awk '{print $2}' | sort`
KOPIE=`grep -R -e '^Message-ID:' $copyofmbox | awk '{print $2}' | sort`

some diff and some improved awking (spaces won't work in case of spaces in folder names) is not a sufficient way to create a list of files, which might be deleted in the original mailbox?

That sounds like a reasonable approach, but obviously you should be careful anytime you modify the cyrus files directly. :)

	Andy
----
Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html

[Index of Archives]     [Cyrus SASL]     [Squirrel Mail]     [Asterisk PBX]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [KDE]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux