Complete.Org: Mailing Lists: Archives: offlineimap: January 2008:
Re: patch to prevent mkdir '.'
Home

Re: patch to prevent mkdir '.'

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: offlineimap@xxxxxxxxxxxx
Subject: Re: patch to prevent mkdir '.'
From: "David L. Emerson" <demerson3x@xxxxxxxxxxxxx>
Date: Thu, 3 Jan 2008 15:41:58 -0800

On Thursday 03 January 2008 8:17 am, you wrote:
> On Thu December 27 2007 1:52:27 pm David L. Emerson wrote:
> > I was having trouble getting offlineimap to play nice with dovecot
> > and kmail, and I ended up making an oddball nametrans that changes
> > the name of the inbox folder to '.'
> > dovecot_kmail_re = re.compile('^\.?(inbox[./])?', re.IGNORECASE)
> > # fn is folder name
> > def fix_dovecot_kmail (fn):
> >     if fn.lower() in ('inbox', '.inbox', '.'):
> >         return '.'
> >     return dovecot_kmail_re.sub('.INBOX.', fn, 1)
> 
> 
> OK, I'm a bit confused on this here...
> 
> Couldn't you point localfolders to the parent dir of your folder
> hierarchy, then have the name start with, say, "folders/"
> or "folders/.INBOX"?  
> 
> I'm not sure the patch does the right thing.  What if the top-level
> Maildir really doesn't exist?  What error are you getting?
> 

Well ... I played around with this a lot, back when I was setting 
everything up a couple months ago. Your solution may very well be a 
better one!

However, what the patch does is very, very simple: it prevents the 
following call from ever being made:

os.makedirs('.');

Such a call can never be successful: The directory called '.' always 
refers to a directory that already exists. I do not believe such a 
directory can ever be created under any circumstances. (unless you 
change the definitions of 'create' or '.')

The error I received was preceeded by the debug line:
makefolder: calling makedirs "."
(I don't recall if it actually had quotes around it)
Then it was crashing because the os.makedirs call failed, since it 
couldn't create a directory called '.'

So I added those two lines to check if the foldername was '.' and print 
a debug statement. It still successfully creates the "cur" "new" 
and "tmp" folders afterwards.


To directly answer your other question: the top-level maildir in this 
case is the localfolder referred to in ~/.offlineimaprc:

[Repository local-ab-3b]
type = Maildir
localfolders = /Docs/email/offlineimap/ab-3b   <--- that one!

so if the top-level maildir doesn't exist, something else much earlier 
is going to catch that and say "localfolders doesn't exist!"

This code here that I've patched would never have created my localfolder 
ab-3b, and that is the folder that '.' is referring to.

hehe, are you less confused, or more so? :)

~David.




[Prev in Thread] Current Thread [Next in Thread]