Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Gaute Hope <eg@gaute.vetsj.com>
To: sup-devel <sup-devel@rubyforge.org>
Subject: Re: A maildir root source: syncing labels with maildirs (imap folders)
Date: Mon, 25 Nov 2013 22:51:09 +0100	[thread overview]
Message-ID: <1385415206-sup-5054@qwerzila> (raw)
In-Reply-To: <1385392376-sup-8491@qwerzila>


[-- Attachment #1.1: Type: text/plain, Size: 3144 bytes --]

Hi,

I have attached my relevant configs (and hopefully managed to anonymize
them enough). As you can see I use the 'utf7.py' module (placed in
~/.offlineimap/) to decode/encode between imap4-utf-7 and utf-8 on
system (if your filesystem uses a different encoding you might have
issues). Please don't use the configs verbatim, but rather as
inspiration: I might have cut out important parts. Some of this is
in the wiki.

Some of the folders are translated (bi-directional of course) in my
offlineimaprc, but if you check out my sources.yaml you will see that I
have specified which folders are related to special (deleted, starred,
inbox, etc) for some of the sources.

My translation setup in offlineimaprc for my first GMail account
corresponds to the default values the maildirroot source suggests. The
only relevant change in config.yaml is to set sync_back_to_maildir:
true.

The way I set up sup with maildirroot is:
$ sup-config

fill in, don't add any sources. If you have a working config.yaml, you
can use it.

add sources:
$ sup-add maildirroot:///home/gaute/.mail/imap_account

I edit ~/.sup/sources.yaml and enable:
- confirm_enable_experimental: true
- sync_back: true
- maildir_creation_allowed: true

and tweak the folder names if necessary.

Then if your index is empty (you _cannot_ merge an existing maildir
source by using the same source id) - I run sup-sync:
$ sup-sync -v

Note that sup-sync does not support the :updated flag (when a message
has moved on disk), for that you have to run regular Sup and do a poll.
sup-sync scans through and adds labels; you can also just start up sup
and see what happens, but that takes a longer time: you probably do not
need to enable the stuff in sources.yaml before after sup-sync if you
are nervous (I would be!). 

Some annoying issues:
- deleting a maildir is hard:
  * if you delete it remotely it will be recreated by offlineimap (i
    think)
  * you have to first remove all emails remotely, sync sup, to make sure
    labels are removed.
  * if you remove all messages from a label the maildir will be empty,
    to delete the maildir: sync, delete the maildir locally + delete it
    remotely; then re-sync.

    this is the behaviour of offlineimap, but I think it is hard to do
    it differently. this means that if you accidentally add a bogus
    label, it is a bit of a pain to get rid of the maildir.


- if a message is deleted from the inbox remotely (archived) it is not
  removed from the inbox view (or any thread index view it is visible
  in) before sup is restarted.

To test maildirroot:
checkout my branch; make the gem: $ rake gem and install it: $ gem
install pkg/sup-999.gem. If develop has changed you can try to merge it in
first.

Again; please make a backup copy of your .mail so that you can restore
it if it turns out maildirroot has been eating or multiplying emails :)

I probably don't have the time to difficult bugs, but I would be happy
to accept patches and I could also put this branch on official Sup if it
turns out to be worth something.


Cheers, Gaute

[-- Attachment #1.2: offlineimaprc --]
[-- Type: application/octet-stream, Size: 3998 bytes --]

[general]
accounts = gaute.vetsj.com, vetsj.com, imap_1, imap_2
#ui = Noninteractive.Basic
pythonfile = ~/.offlineimap/utf7.py
autorefresh = 3

[Account gaute.vetsj.com]
localrepository = LocalVetsj
remoterepository = RemoteVetsj

[Repository LocalVetsj]
type = Maildir
localfolders = /home/gaute/.mail/gaute.vetsj.com
nametrans: lambda s: dict((value,key) for key,value in
                      {  '[Gmail]/Starred' : 'starred',
                         '[Gmail]/Trash'   : 'trash',
                         '[Gmail]/Spam'    : 'spam',
                         '[Gmail]/Sent Mail' : 'sent',
                         '[Gmail]/Important' : 'important',
                         '[Gmail]/Drafts'    : 'drafts',
                         '[Gmail]/All Mail'  : 'archive',
                         'INBOX'             : 'inbox',
                      }.iteritems()).get (s, s).decode ('utf8').encode ('imap4-utf-7')

[Repository RemoteVetsj]
type = Gmail
ssl = yes
nametrans: lambda s: {  '[Gmail]/Starred' : 'starred',
                        '[Gmail]/Trash'   : 'trash',
                        '[Gmail]/Spam'    : 'spam',
                        '[Gmail]/Sent Mail' : 'sent',
                        '[Gmail]/Important' : 'important',
                        '[Gmail]/Drafts'    : 'drafts',
                        '[Gmail]/All Mail'  : 'archive',
                        'INBOX'             : 'inbox',
                      }.get (s, s).decode ('imap4-utf-7').encode ('utf8')

#folderfilter = lambda foldername: foldername in ['[Gmail]/All Mail']

[Account vetsj.com]
localrepository = LocalVetsjCom
remoterepository = RemoteVetsjCom

[Repository LocalVetsjCom]
type = Maildir
localfolders = /home/gaute/.mail/vetsj.com
nametrans: lambda s: dict((value,key) for key,value in
                      {  '[Gmail]/Starred' : 'starred',
                         '[Gmail]/Trash'   : 'trash',
                         '[Gmail]/Spam'    : 'spam',
                         '[Gmail]/Sent Mail' : 'sent',
                         '[Gmail]/Important' : 'important',
                         '[Gmail]/Drafts'    : 'drafts',
                         '[Gmail]/All Mail'  : 'archive',
                         'INBOX'             : 'inbox',
                      }.iteritems()).get (s, s).decode ('utf8').encode ('imap4-utf-7')

[Repository RemoteVetsjCom]
type = Gmail
ssl = yes
nametrans: lambda s: {  '[Gmail]/Starred' : 'starred',
                        '[Gmail]/Trash'   : 'trash',
                        '[Gmail]/Spam'    : 'spam',
                        '[Gmail]/Sent Mail' : 'sent',
                        '[Gmail]/Important' : 'important',
                        '[Gmail]/Drafts'    : 'drafts',
                        '[Gmail]/All Mail'  : 'archive',
                        'INBOX'             : 'inbox',
                      }.get (s, s).decode ('imap4-utf-7').encode ('utf8')


[Account imap_1]
localrepository = Local_imap1
remoterepository = Remote_imap1

[Repository Local_imap1]
type = Maildir
localfolders = /home/gaute/.mail/imap_1
nametrans = lambda s: s.replace ('archive', 'Archives').replace ('drafts', 'Drafts').replace ('sent', 'Sent').replace ('trash', 'Trash').decode ('utf8').encode ('imap4-utf-7')

[Repository Remote_imap1]
type = IMAP
remotehost = imap_1
nametrans  = lambda s: s.replace ('Archives', 'archive').replace ('Drafts', 'drafts').replace ('Sent', 'sent').replace ('Trash', 'trash').decode ('imap4-utf-7').encode ('utf8')

[Account imap_2]
localrepository = Local_imap2
remoterepository = Remote_imap2

[Repository Local_imap2]
type = Maildir
localfolders = /home/gaute/.mail/imap_2
nametrans: lambda s: dict((value,key) for key,value in
                      {  'INBOX'             : 'inbox',
                      }.iteritems()).get (s, s).decode ('utf8').encode ('imap4-utf-7')

[Repository Remote_imap2]
type = IMAP
remotehost = imap_2
nametrans: lambda s: {  'INBOX'             : 'inbox',
                      }.get (s, s).decode ('imap4-utf-7').encode ('utf8')


[-- Attachment #1.3: utf7.py --]
[-- Type: application/x-python, Size: 2213 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.4: sources.yaml --]
[-- Type: text/x-yaml; name="sources.yaml", Size: 1560 bytes --]

---
- !supmua.org,2006-10-01/Redwood/MaildirRoot
  uri: maildirroot:/home/gaute/.mail/gaute.vetsj.com/
  usual: true
  archived: false
  id: 1
  labels: []
  sync_back: true
  confirm_enable_experimental: true
  maildir_creation_allowed: true
  inbox_folder: inbox
  sent_folder: sent
  drafts_folder: drafts
  spam_folder: spam
  trash_folder: trash
  archive_folder: archive
- !supmua.org,2006-10-01/Redwood/MaildirRoot
  uri: maildirroot:/home/gaute/.mail/vetsj.com/
  usual: true
  archived: false
  id: 2
  labels: []
  sync_back: true
  confirm_enable_experimental: true
  maildir_creation_allowed: true
  inbox_folder: inbox
  sent_folder: sent
  drafts_folder: drafts
  spam_folder: spam
  trash_folder: trash
  archive_folder: archive
- !supmua.org,2006-10-01/Redwood/MaildirRoot
  uri: maildirroot:/home/gaute/.mail/imap_1
  usual: true
  archived: false
  id: 3
  labels:
  - some_1 =

  sync_back: true
  confirm_enable_experimental: true
  maildir_creation_allowed: true
  inbox_folder: INBOX
  sent_folder: sent
  drafts_folder: drafts
  spam_folder: spam
  trash_folder: trash
  archive_folder: archive
- !supmua.org,2006-10-01/Redwood/MaildirRoot
  uri: maildirroot:/home/gaute/.mail/imap_2
  usual: true
  archived: false
  id: 4
  labels:
  - some_2 =

  sync_back: true
  confirm_enable_experimental: true
  maildir_creation_allowed: true
  inbox_folder: inbox
  sent_folder: Sent Items
  drafts_folder: Drafts
  spam_folder: Junk E-mail
  trash_folder: Deleted Items
  archive_folder: archive
- !supmua.org,2006-10-01/Redwood/SentLoader {}

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.5: config.yaml --]
[-- Type: text/x-yaml; name="config.yaml", Size: 603 bytes --]

[...]
:editor: vim -f -c 'set ft=3Dmail' '+/^\s*\n/' '+nohl'
:confirm_no_attachments: true
:thread_by_subject: false
:edit_signature: false
:ask_for_from: false
:ask_for_to: true
:ask_for_cc: false
:ask_for_bcc: false
:ask_for_subject: true
:account_selector: true
:confirm_top_posting: false
:jump_to_open_message: true
:discard_snippets_from_encrypted_messages: false
:load_more_threads_when_scrolling: true
:default_attachment_save_dir: ''
:sent_source: sup://sent
:archive_sent: true
:poll_interval: 300
:wrap_width: 0
:slip_rows: 0
:col_jump: 2
:stem_language: english
:sync_back_to_maildir: true


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2013-11-25 21:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25 15:24 Gaute Hope
2013-11-25 18:23 ` [sup-devel] " Steven Schmeiser
2013-11-25 21:08 ` Matthieu Rakotojaona
2013-11-25 21:51 ` Gaute Hope [this message]
2013-11-25 22:28   ` Gaute Hope
2013-11-26 14:43   ` [sup-devel] " Steven Schmeiser
2013-11-26 15:14     ` Gaute Hope
2013-11-26 16:42       ` Steven Schmeiser
2013-11-26 16:55         ` Gaute Hope
2013-11-27  0:48           ` Steven Schmeiser
2013-11-27  6:21             ` Gaute Hope
2013-11-27 12:42               ` Steven Schmeiser
2013-11-27 13:08                 ` Gaute Hope
2013-11-27 13:24                   ` Gaute Hope
2013-11-27 18:32                   ` Matthieu Rakotojaona
2013-11-27 21:10                     ` Gaute Hope
2013-11-29  9:22                       ` Gaute Hope
2013-11-27  6:23           ` Gaute Hope

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1385415206-sup-5054@qwerzila \
    --to=eg@gaute.vetsj.com \
    --cc=sup-devel@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox