{"id":18104272,"url":"https://github.com/gauteh/abunchoftags","last_synced_at":"2025-04-13T19:32:37.103Z","repository":{"id":22636833,"uuid":"25979627","full_name":"gauteh/abunchoftags","owner":"gauteh","description":"(DISCONTINUED, use gmailieer) experimental tag syncing between gmail tags (using X-Keywords) and notmuch tags","archived":false,"fork":false,"pushed_at":"2017-05-14T20:39:49.000Z","size":73,"stargazers_count":16,"open_issues_count":3,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-27T10:11:31.433Z","etag":null,"topics":["gmail","gmail-labels","notmuch","offlineimap","sync"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gauteh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-30T16:28:09.000Z","updated_at":"2023-09-08T16:51:47.000Z","dependencies_parsed_at":"2022-07-27T03:02:20.886Z","dependency_job_id":null,"html_url":"https://github.com/gauteh/abunchoftags","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gauteh%2Fabunchoftags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gauteh%2Fabunchoftags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gauteh%2Fabunchoftags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gauteh%2Fabunchoftags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gauteh","download_url":"https://codeload.github.com/gauteh/abunchoftags/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248767953,"owners_count":21158563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gmail","gmail-labels","notmuch","offlineimap","sync"],"created_at":"2024-10-31T22:14:27.320Z","updated_at":"2025-04-13T19:32:37.080Z","avatar_url":"https://github.com/gauteh.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# keywsync\n\nattempts to synchronize notmuch tags between the X-Keywords header of\nmessages and the notmuch database.\n\n## Disclaimer\n\nThis is highly experimental. It will modify you emails. It may totally destroy all your email. Use at own risk.\n\n## Things to be aware of\n\nCheck out `keywsync.hh` to see which tags are ignored and how the mappings are\ndone. I also replace `/` with `.`, so if you got any tags with `.` in them it\nis going to become a mess. This can be controlled with `--replace-chars` and\n`--no-replace-chars`.\n\nAlso, there is no support for tags with spaces in them (they should probably be\nwrapped in quotes at some point). Make sure you have a recent version of\nOfflineIMAP, some issues with [multiple occurences of\ntags](https://github.com/OfflineIMAP/offlineimap/pull/136) should be fixed\nthere.\n\n## Usage\n\n## Remote to local\n\nAdd all tags from remote to notmuch db:\n\n`$ ./keywsync -m /path/to/db -k -p -a -q query`\n\nRemove all tags from notmuch db that are not in remote:\n\n`$ ./keywsync -m /path/to/db -k -p -r -q query`\n\nDo both in one go:\n\n`$ ./keywsync -m /path/to/db -k -p -q query`\n\n#### Note:\nTypically use a query with `tag:new`, but since notmuch will not detect a\nchange within a message (say a keyword has been changed on an existing message)\nit is necessary to run this on all messages now and then to ensure all remote\ntag changes have been caught.\n\n## Local to remote\n\nAdd all tags from local to remote:\n\n`$ ./keywsync -m /path/to/db -t -p -a -q query`\n\nRemove all tags from local to remote:\n\n`$ ./keywsync -m /path/to/db -t -p -r -q query`\n\nDo both in one go:\n\n`$ ./keywsync -m /path/to/db -t -p -q query`\n\n## Strategy:\n\nAssuming you have fully synced database and you want to synchronize your\nmaildir with the remote maildir:\n\n\u003e  Note: The query needs to filter messages so that only the messages of the\n\u003e  GMail maildir are tested.\n\nSee this example: [fetch_and_sync.sh](examples/fetch_and_sync.sh).\n\n1. Synchronize tags local-to-remote (`-t`), now all tag changes done in the\n   notmuch db are synchronized with the message files (preferably using a\n   `lastmod:` query [1] which catches messages where changes have been done after\n   the revision of the db at the time of the last remote-to-local synchronization)\n\n1. Save the current unix time: `$ before_offlineimap=$( date +%s )`\n\n1. Run `offlineimap` to synchronize your local maildir and messages with the\n   remote. According to the offlineimap documentation [0] the X-Keywords flags\n   are synchronized in the same way as maildir flags (whatever that means [2]).\n\n1. Run `notmuch new` to detect any new or deleted files, or and renames.\n\n1. Synchronize tags remote-to-local (`-k`) using a `query` that filters out anything\n   but the maildir in question. Use the `--mtime` flag to only sync messages that match\n   the `query` and are modified after offlineimap was run: `echo $before_offlineimap`.\n\n1. Store the current database revision for the next `lastmod` search in the\n   local-to-remote step of your next search: `$ notmuch_get_revision\n   /path/to/db`. Alternatively, store the revision from before the\n   local-to-remote sync. In that way it is possible to detect local changes\n   that happened during the sync. This will re-check the messages that were\n   modified as part of the remote-to-local sync.\n\n\u003e Note: `notmuch new` does not detect message changes that do not include a file addition,\n\u003e removal or rename. Therefore simple changes to the `X-Keywords` header will not be detected.\n\u003e Use the **--mtime** query to filter out unchanged files.\n\n## Initial sync\n\nIf you wish to discard all local tags, start with  a `remote-to-local` sync with a query\nmatching the entire directory.\n\nIf you wish to discard all remote tags, start with a `local-to-remote` sync.\n\nYou might be able to preserve some stuff using the `--only-add` and `--only-remove` flags during\nsync. Otherwise dumping notmuch tags and restoring at a later time when you have brought your local\ncopy up-to-date with the remote might work.\n\n## Timing\n\nRunning a full keyword-to-tag sync on a Macbook Pro with around 55k messages on an encfs volume\ntook 1m48s and used about 108MB of memory.\n\nRunning a full tag-to-keyword check on the same message base with 3 changed messages\ntook about 1m5s and 100MB of memory.\n\n\n## References\n\n[0] http://offlineimap.readthedocs.org/en/next/MANUAL.html?highlight=keywords#sync-from-gmail-to-a-local-maildir-with-labels  \n[1] id:1413181203-1676-1-git-send-email-aclements@csail.mit.edu  \n[2] Someone have any documentation [anywhere?](https://github.com/OfflineIMAP/offlineimap/issues/130)\n\n#### Other resources\n\nAccess to GMail labels via IMAP extensions: https://developers.google.com/gmail/imap_extensions#access_to_gmail_labels_x-gm-labels  \nCommit in OfflineIMAP for GMail label support: https://github.com/OfflineIMAP/offlineimap/commit/0e4afa913253c43409e6a32a6b6e11e8b03ed3d9  \nOriginal patch for OfflineIMAP: http://thread.gmane.org/gmane.mail.imap.offlineimap.general/5943/focus=5970  \nSpecial tags for notmuch: http://notmuchmail.org/special-tags/  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgauteh%2Fabunchoftags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgauteh%2Fabunchoftags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgauteh%2Fabunchoftags/lists"}