offlineimap icon indicating copy to clipboard operation
offlineimap copied to clipboard

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

Open pascalfleury opened this issue 6 years ago • 2 comments

General informations

  • system/distribution (with version): Ubuntu 14.04.5 LTS
  • offlineimap version (offlineimap -V): offlineimap v7.2.3, imaplib2 v2.57 (system), Python v2.7.16, OpenSSL 1.1.1c 28 May 2019
  • Python version: Python 2.7.16
  • server name or domain: gmail
  • CLI options: none

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 = <[email protected]>
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

  • Create some GMail labels, e.g. '.S' and '.S/Next' and '.S/Done'
  • try to sync them to a local maildir.

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

pascalfleury avatar Oct 02 '19 20:10 pascalfleury

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

nicolas33 avatar Oct 03 '19 22:10 nicolas33

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

thekix avatar Sep 04 '20 05:09 thekix