nametrans confusion ...

Cameron Simpson cs at zip.com.au
Tue Feb 14 07:01:43 GMT 2012


On 08Feb2012 14:58, Allan Wind <allan_wind at lifeintegrity.com> wrote:
| On 2012-02-08 14:49:43, Allan Wind wrote:
| > When you are debugging the basic ui is useful, also try use the 
| > -1 option:
| > 
| > offlineimap.py -1 -d imap -u basic
| 
| ... and try (re)move your state:
| 
| rm -fr ~/.offlineimap
| 
| or whatever you have metadata set to.

Well, I've been doing some more experiments (the real world got in my
way last week, not least having to rebuild the server I'm testing
against:-)

I have convinced myself that offlineimap doesn't keep "local" mailbox
names and "remote" ones cleanly separate. Or that I still have no idea
what's going on.

You may recall my maildirs are in an "MD/" namespace on the IMAP server.

I've managed to to sync my local OLD/2012/hg maildir against the IMAP
MD/OLD/2012/hg folder, but my debugging makes it clear extra stuff is
happening. I'm using these functions:

  def here2there(f):
    rf = prepath + f.replace('.', '/')      ## .replace('/', '.')
    if myfolders(f): print >>sys.stderr, "here2there(%s) -> %s" % (f, rf)
    return rf

  def there2here(rf):
    f = (rf[len(prepath):] if rf.startswith(prepath) else rf)
    if myfolders(f): print >>sys.stderr, "there2here(%s) -> %s" % (rf, f)
    return f

  def myfolders(f):
    useme = 'hg' in f and 'OLD' in f and '2012' in f
    if useme: print >>sys.stderr, "myfolders(%s) -> %s" % (f, useme)
    return useme

The latest trace goes:

  OfflineIMAP 6.5.2.1
    Licensed under the GNU GPL v2+ (v2 or any later version)
  *** Processing account _Users_cameron_mail::cameron at cskk.local:143
  Establishing connection to cskk.local:143
  myfolders(OLD/2012/hg) -> True
  there2here(MD/OLD/2012/hg) -> OLD/2012/hg
  myfolders(MD/OLD/2012/hg) -> True
  myfolders(OLD/2012/hg) -> True
  here2there(OLD/2012/hg) -> MD/OLD/2012/hg
  myfolders(OLD/2012/hg) -> True
  myfolders(OLD.2012.hg) -> True
  here2there(OLD.2012.hg) -> MD/OLD/2012/hg
  myfolders(OLD.2012.hg) -> True
  here2there(OLD.2012.hg) -> MD/OLD/2012/hg
  Syncing MD/OLD/2012/hg: IMAP -> Maildir
  *** Finished account '_Users_cameron_mail::cameron at cskk.local:143' in 0:03

Some remarks:

1: It appears that offlineimap wants to put "." as a name separator
   somewhere in this. I do not use a "." myself anywhere.

   As a consequence, I have a gratuitous "replace('.', '/')" in my
   here2there function. You can see in the trace that it is called
   against "OLD/2012/hg" (which I expect) and _also_ against
   "OLD.2012.hg", which seems bogus.

   It is also why I'm testing against OLD and 2012 and hg separately in
   myfolders().

2: The folderfilter seems to be called against all manner of folders,
   both local and remote. That seems very wrong. Surely it should be
   called only against local names? Of by distinct folters for local nd
   remote.

I append the offlineimaprc below.

Cheers,
Cameron Simpson <cs at zip.com.au>

[general]
accounts = _Users_cameron_mail::cameron at cskk.local:143
metadata = /Users/cameron/.offlineimap
ui = basic
##ui = Blinkenlights
fsync = false
pythonfile = ~/offl.py

[Account _Users_cameron_mail::cameron at cskk.local:143]
localrepository = _Users_cameron_mail
remoterepository = cameron at cskk.local:143
folderfilter = lambda f: myfolders(f)

[Repository _Users_cameron_mail]
type = Maildir
localfolders = /Users/cameron/mail
sep = /
nametrans = lambda foldername: here2there(foldername)
folderfilter = lambda f: myfolders(f)

[Repository cameron at cskk.local:143]
type = IMAP
nametrans = lambda foldername: there2here(foldername)
remotehost = cskk.local
remoteuser = cameron
##remotepassword = 
remotepassfile = ~/private/passwd.cameron at cskk.local:143




More information about the OfflineIMAP-project mailing list