Configuration boilerplate

Dave Abrahams dave at boostpro.com
Thu Aug 25 16:17:12 BST 2011


on Wed Aug 24 2011, Sebastian Spaeth <Sebastian-AT-SSpaeth.de> wrote:

>> > For this you could simply specify a foldersort argument so that "INBOX" comes
>> > before "All Mail" :). This way you don't need 2 accounts for that issue,
>> > so that can be solved.
>> 
>> From what I can tell, it won't help if there's a lot to sync in "All
>> Mail".  Maybe now that I have my initial sync done it's not an issue
>> anymore, but when I was getting things set up it didn't seem to get back
>> around to sync'ing "INBOX" as long as there was lots left to sync in
>> "All Mail."
>
> But with a foldersort that let INBOX be synced *before* All Mail, it
> shouldn't even reach All Mail as long as there is still stuff to sync in
> INBOX. That having said, I personally never tried foldersort, so I am
> not sure if it works as advertized.

Scenario: it takes hours to sync "All Mail."  INBOX syncs in seconds,
but I want to continue to receive mail in my INBOX while "All Mail" is
syncing.  Even if syncing starts with INBOX, it gets "stuck" doing hours
of work on "All Mail" and I can't read anything in INBOX in the
meantime.

As I said, this is probably not a big issue now that "All Mail" has
synced once, but I dread the day when I have to re-sync (it took me a
few tries to do the initial sync) or simply want to set this up on
another machine, or (god forbid) decide I want to rename an account or a
folder.

>> Sure, I wouldn't think of doing that.  However if it's that dangerous,
>> offlineimap should check for it and prevent me from shooting myself in
>> the foot.
>
> Sure, but this would require that something global keeps tab of all used
> maildir folders across accounts. 

Huh?  Just have a step at startup that validates the config file, neh?

> The way OfflineImap is designed has Accounts be totally different
> operations that know nothing of each other, and even folders are
> pretty much separated (which is one of the reasons why it would be
> hard to detect moves of mails between folders).

I don't see the problem here, sorry.

>> Well, as you can see the INBOX from my Personal Gmail doesn't go into my
>> local INBOX; they are separate folders.
>
> I know and that is fine. I just said, if you (or someone copying your
> setup) ever loosen the folderfilter rules and both have, say "Drafts" be
> synced to .Drafts (as it would happen in your case), trouble could
> ensue. Your setup is fine. I just wanted to point out the potential
> pitfalls.

Thanks.

>> My advice: start with prevention, then document.
>> 
>> >  but I only recognized this
>> > some while ago myself. Our docs deserve some love!
>> 
>> Sooooo.... you never got around to answering my original question.  How
>> do I eliminate some of the boilerplate repetition?
>
> Mmh, 120 lines or so to configure 5 accounts including comments and
> blank lines. I don't see many ways to cut that down a lot
> (sep=. is default for Maildirs, so you could drop that)
> pythonfile= allows you to specify functions for many settings, but you
> would still need to specify them in the Accounts and Repository
> sections.
>
> I would try to see it positive, I find the configuration much shorter
> than a proper muttrc :). If you know of any ways that would make life
> easier for you, let us know and I'll put it on my list.

I thought you'd never ask ;-)

My first thought was to give me (documented) programmatic access to the
configuration so I can write Python code that builds whole sections of
the config file.  However, it occurs to me that a one syntactic
extension could reduce my config considerably.  I've rewritten it below
using an "inherit =" clause for each remote repository.

--8<---------------cut here---------------start------------->8---
[general]
accounts = BoostPro,Spam,ArchiveSync,PersonalGMail
maxsyncaccounts = 5
fsync = false


[Repository BoostProLocal]
type = Maildir
sep = .
localfolders = ~/Library/Data/LocalIMAP
postsynchook = imap-postsync localhost dave
restoreatime = no

[Repository GMailIMAP]
type = IMAP
remotehost = imap.gmail.com
remoteuser = dave-AT-boostpro.com
remotepass = <myremotepass>
ssl = yes
realdelete = yes
nametrans = lambda folder: '.' if folder == 'INBOX' else '.' + folder
holdconnectionopen = yes
keepalive = 60

######################
# Accounts           #
######################

###### BoostPro ########

[Account BoostPro]
localrepository = BoostProLocal
remoterepository = BoostProRemote
autorefresh = 15
quick = 3

[Repository BoostPro]
inherit = GMailIMAP
folderfilter = lambda foldername: foldername in ['INBOX']
idlefolders = ['INBOX']

######################

[Account ArchiveSync]
localrepository = BoostProLocal
remoterepository = ArchiveRemote
autorefresh = 15
quick = 3

[Repository ArchiveRemote]
inherit = GMailIMAP
type = IMAP
folderfilter = lambda foldername: foldername in ['[Gmail]/All Mail']
idlefolders = ['[Gmail]/All Mail']

######################

[Account PersonalGMail]
localrepository = BoostProLocal
remoterepository = PersonalGMailRemote
autorefresh = 40
quick = 3

[Repository PersonalGMailRemote]
inherit = GMailIMAP
remoteuser = dave.abrahams-AT-gmail.com
remotepass = <anotherremotepass>
folderfilter = lambda foldername: foldername in ['INBOX']
nametrans = lambda folder: '.PersonalGMail' if folder == 'INBOX' else '.' + folder
idlefolders = ['PersonalGMail']

######################

[Account Spam]
localrepository = BoostProLocalReadOnly
remoterepository = BoostProRemoteSpam
autorefresh = 16
quick = 8
holdconnectionopen = no

[Repository BoostProLocalReadOnly]
inherit = BoostProLocal
readonly = true

[Repository BoostProRemoteSpam]
inherit = GMailIMAP
folderfilter = lambda foldername: foldername in ['[Gmail]/Spam']
idlefolders = []
--8<---------------cut here---------------end--------------->8---

> A readonlyfolders = lambda x: ['Spam','Archive.*'] setting on a repository does
> sound like a good idea to start with. (or similar)

+1

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com




More information about the OfflineIMAP-project mailing list