OfflineIMAP / offlineimap

Read/sync your IMAP mailboxes (python2) [LEGACY: move to offlineimap3]
http://www.offlineimap.org
Other
1.78k stars 360 forks source link

GMail folders starting with '.' (dot) do not get synced #629

Open pascalfleury opened 5 years ago

pascalfleury commented 5 years ago

General informations

Why using dots ? Because they get sorted before the other labels in the right hand-side of GMail, as there is no other way to sort them than using the ASCII order.

Configuration file offlineimaprc

[general]
accounts = Gmail

[Account Gmail]
localrepository = Gmail-local
remoterepository = Gmail-remote

[Repository Gmail-local]
type = Maildir
localfolders = ~/Maildir

[Repository Gmail-remote]
type = Gmail
remoteuser = <user@gmail.com>
auth_mechanisms = XOAUTH2
oauth2_client_id = <redacted>
oauth2_client_secret = <redacted>
oauth2_request_url = https://accounts.google.com/o/oauth2/token
oauth2_refresh_token = <redacted>
folderfilter = lambda folder: folder.startswith('.S/') or folder in ['C/Blackswan', '[Gmail]/Drafts', '[Gmail]/Sent MailX', '[Gmail]/Trash'] or re.search('Draft', folder)
nametrans=lambda folder: re.sub('^\[Gmail\]/', '', re.sub('.S/', 'S.', folder))
createfolders = False
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

Logs, error

offlineimap --info will tell me that it does see the folders on Google's IMAP, will keep then through the folderfilter, and will do the nametrans properly.

olderfilter= lambda folder: folder.startswith('S/') or folder in ['C/Blackswan', '[Gmail]/Drafts', '[Gmail]/Sent MailX', '[Gmail]/Trash'] or re.search('Draft', folder)

nametrans= lambda folder: re.sub('^\[Gmail\]/', '', re.sub('.S/', 'S.', folder))

Folderlist:
 C/Blackswan
 [Gmail]/Drafts -> Drafts
 .S/Action -> S.Action
 .S/Next -> S.Next
 .S/Read -> S.Read
 .S/Some Day -> S.Some Day
 .S/Waiting On -> S.Waiting On
 [Gmail]/Trash -> Trash

Local repository 'Gmail-local': type 'Maildir'
Folderlist:
 S.Next
 Trash
 S.Some Day
 C.Blackswan
 S.Read
 S.Action
 S.Waiting On
 Drafts

but then when syncing, it will only sync Trash (empty in my case) and Drafts. I also tried without the nametrans, and did not wait until my xxGB would sync without the folderfilter.

Steps to reproduce the error

Notice that dirs get created, but that's about it.

nicolas33 commented 5 years ago

Could you enable the debug logs and paste the result, please? (be care with presonal/confidential information there)

thekix commented 4 years ago

Hi,

is the regex fine?

nametrans= lambda folder: re.sub('^\[Gmail\]/', '', re.sub('.S/', 'S.', folder))

Could you try this one? The dot is "any character" and probably you want the dot character, so you need scape it (\.):

nametrans= lambda folder: re.sub('^\[Gmail\]/', '', re.sub('\.S/', 'S.', folder))

Cheers, kix