Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

understanding nametrans #547

Closed
bootzin opened this issue May 6, 2018 · 12 comments
Closed

understanding nametrans #547

bootzin opened this issue May 6, 2018 · 12 comments
Labels

Comments

@bootzin
Copy link

bootzin commented May 6, 2018

General informations

  • system/distribution (with version): Linux titan 4.16.6-1-ARCH Missing master commit #1 SMP PREEMPT Mon Apr 30 12:30:03 UTC 2018 x86_64 GNU/Linux
  • offlineimap version (offlineimap -V): offlineimap v7.2.0, imaplib2 v2.57 (bundled), Python v2.7.15, OpenSSL 1.1.0h 27 Mar 2018
  • Python version: Python 2.7.15
  • server name or domain: imap.gmail.com
  • CLI options: none

Configuration file offlineimaprc

[general]
ui = ttyui
accounts = Gmail

[Account Gmail]
localrepository = Gmail-Local
remoterepository = Gmail-Remote

[Repository Gmail-Local]
type = GmailMaildir
localfolders = ~/Mail/Gmail
nametrans = lambda f: '[Gmail]/' + f if f in ['Drafts', 'Starred', 'Important', 'Spam', 'Trash', 'All Mail', 'Sent Mail', 'Sent'] else f

[Repository Gmail-Remote]
type = Gmail
remotehost = imap.gmail.com
ssl = yes
starttls = no
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
auth_mechanisms = XOAUTH2
nametrans = lambda f: f.replace('[Gmail]/', '') if f.startswith('[Gmail]/') else f

Steps to reproduce the error

  • I simply synced offlineimap with no CLI options, tha mail synced the "Sent" folder completely, and then deleted all mails from it
    "Folder Sent [acc: Gmail]:
    Syncing Sent: Gmail -> GmailMaildir
    Copy message UID 7 (1/149) Gmail-Remote:Sent -> Gmail-Local:Sent
    "
    [...]
    "Folder Sent [remote name [Gmail]/Sent] [acc: Gmail]:
    Syncing [Gmail]/Sent: Gmail -> GmailMaildir
    Deleting 149 messages (7:155) in GmailMaildir[Sent]
    "
@nicolas33
Copy link
Member

Is this reproducible?

@bootzin
Copy link
Author

bootzin commented May 6, 2018

It happens every single time I sync, I can't see my "Sent" mail because they get deleted
If I open neomutt during the sync though, I can see the mails that are being downloaded, but as soon as it finishes downloading them, they get deleted

@bootzin bootzin changed the title All mais form a folder being deleted after being synced All mais from a folder being deleted after being synced May 6, 2018
@nicolas33
Copy link
Member

If I open neomutt during the sync though, I can see the mails that are being downloaded, but as soon as it finishes downloading them, they get deleted

As soon as offlineimap sync is done? Without any new sync? What deletes them?

@bootzin
Copy link
Author

bootzin commented May 6, 2018

As soon as offlineimap is done and I resync neomutt. Offlineimap itself deletes the mails from my computer

@bootzin
Copy link
Author

bootzin commented May 6, 2018

Also, after it deletes from the "Sent" folder, it creates a new "Sent Mail" folder and starts downloading the same mails that have just been deleted, but these ones are ept in the machine after the sync though. Any idei of why is this happening?

@nicolas33
Copy link
Member

after it deletes from the "Sent" folder, it creates a new "Sent Mail" folder and starts downloading the same mails that have just been deleted, but these ones are ept in the machine after the sync though.

This sounds like a nametrans issue but I still don't get how emails are deleted.

You said offlineimap is done so it's not offlineimap which is deleting the emails. It only sync the deletions back to the server.

What's the output of offlineimap --info?

@nicolas33
Copy link
Member

Ok, I think I got it. Check your nametrans:

local:
nametrans = lambda f: '[Gmail]/' + f if f in ['Drafts', 'Starred', 'Important', 'Spam', 'Trash', 'All Mail', 'Sent Mail', 'Sent'] else f

remote:
nametrans = lambda f: f.replace('[Gmail]/', '') if f.startswith('[Gmail]/') else f

If you have a folder called Sent on the remote, it's first downloaded as Sent. On next sync it's translated to [Gmail]/Sent.

@nicolas33
Copy link
Member

The output of offlineimap --info should really help.

@bootzin
Copy link
Author

bootzin commented May 6, 2018

Here's the output of offlineimap --info:

OfflineIMAP 7.2.0
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v2.57 (bundled), Python v2.7.15, OpenSSL 1.1.0h  27 Mar 2018
  imaplib2: 2.57 (bundled)
Remote repository 'Gmail-Remote': type 'Gmail'
Host: imap.gmail.com Port: 993 SSL: True
Establishing connection to imap.gmail.com:993 (Gmail-Remote)
Server supports ID extension.
Server welcome string: * OK Gimap ready for requests from 2804:14c:5bd7:902e:9b9f:5730:a19d:123 d65mb469571804qkg
Server capabilities: ('IMAP4REV1', 'UNSELECT', 'IDLE', 'NAMESPACE', 'QUOTA', 'ID', 'XLIST', 'CHILDREN', 'X-GM-EXT-1', 'UIDPLUS', 'COMPRESS=DEFLATE', 'ENABLE', 'MOVE', 'CONDSTORE', 'ESEARCH', 'UTF8=ACCEPT', 'LIST-EXTENDED', 'LIST-STATUS', 'LITERAL-', 'SPECIAL-USE', 'APPENDLIMIT=35651584')

nametrans= lambda f: f.replace('[Gmail]/', '') if f.startswith('[Gmail]/') else f

Folderlist:
 [Gmail]/All Mail -> All Mail
 [Gmail]/Drafts -> Drafts
 [Gmail]/Important -> Important
 INBOX
 Sent
 [Gmail]/Sent -> Sent
 Sent Mail
 [Gmail]/Sent Mail -> Sent Mail
 [Gmail]/Spam -> Spam
 [Gmail]/Starred -> Starred
 [Gmail]/Trash -> Trash

Local repository 'Gmail-Local': type 'GmailMaildir'
nametrans= lambda f: '[Gmail]/' + f if f in ['Drafts', 'Starred', 'Important', 'Spam', 'Trash', 'All Mail', 'Sent'] else f

Folderlist:
 All Mail -> [Gmail]/All Mail
 Sent -> [Gmail]/Sent
 Starred -> [Gmail]/Starred
 INBOX
 Important -> [Gmail]/Important
 Drafts -> [Gmail]/Drafts
 Spam -> [Gmail]/Spam
 Trash -> [Gmail]/Trash
 Sent Mail

I'll be honest that I don't exactly understand the 'nametrans' part of the config file, and I couldn't figure out what to change based on this output.. I had copied a config file from someone else, and it worked just fine, but I wanted to change 'Sent Mail' to be simply 'Sent', and then I started running into problems

@nicolas33
Copy link
Member

That's it.

nametrans allows to rename folders. It requires one rule to translate folder names from the remote to the local (in the remote section) and another rule to translate in the opposite direction.

I'm not sure you can remove the '[Gmail]/Sent Mail' because it's the Gmail name. You should connect to the gmail webmail and remove all the other sent folders and do the same in your local maildir (you might like to make a backup). Currently it's a big mess! Run offlineimap --info and save the output.

I think your current nametrans rules are correct to get what you want, now. So, it should be fine on next sync. If not, re-run offlineimap --info and compare to the previous result to better understand what's going on with the nametrans rules.

@nicolas33 nicolas33 changed the title All mais from a folder being deleted after being synced understanding nametrans May 6, 2018
@bootzin
Copy link
Author

bootzin commented May 7, 2018

I had to tweak namtrans a little bit, but now that I got how it works I managed to do it (:
Just for clarification, this what I used to change the "Sent Mail" folder into a "Sent" folder:

[Repository Gmail-Local]
nametrans = lambda f: '[Gmail]/Sent Mail' if f in ['Sent'] else '[Gmail]/' + f if f in ['Drafts', 'Starred', 'Important', 'Spam', 'Trash', 'All Mail', 'Sent Mail'] else f

[Repository Gmail-Remote]
nametrans = lambda f: f.replace('[Gmail]/Sent Mail','Sent') if f.startswith('[Gmail]/Sent Mail') else f.replace('[Gmail]/', '') if f.startswith('[Gmail]/') else f

Thanks a lot for the help (:

@bootzin bootzin closed this as completed May 7, 2018
@nicolas33
Copy link
Member

Thank you for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants