aboutsummaryrefslogtreecommitdiffstats
path: root/worker/notmuch/eventhandlers.go
Commit message (Collapse)AuthorAgeFilesLines
* notmuch: reload all changed messages on DB changeJason Cox2024-08-201-3/+12
| | | | | | | | | | | | | | | | | | | | | | | This reverts commit c56649fe5291b725f14b45550a68cc7d0dc16ff7. As discussed in the aerc-devel thread for the reverted patch, the performance improvement comes with an issue: changes to message tags are no longer immediately reflected in the UI. This issue occurs whether the tags are modified from within aerc or externally with the notmuch CLI. The message list also flickers any time tag changes are made. Further, commit c36ed72e4a59 ("notmuch: speed up lastmod query") dramatically reduces the number of messages which are re-indexed when the database changes, likely eliminating the need for the reverted performance improvement anyway. Fixes: c56649fe5291 ("notmuch: don't reload all message on change") Link: https://lists.sr.ht/~rjarry/aerc-devel/patches/53729 Link: https://lists.sr.ht/~rjarry/aerc-devel/patches/54028 Reported-by: Robin Dapp <rdapp@modk.org> Reported-by: Ryan Winograd <ryan@thewinograds.com> Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: speed up lastmod query.Robin Dapp2024-08-031-1/+1
| | | | | | | | | | | | | | When changing the tag/label of a message we refresh all messages that were modified since the start of the transaction. To that end we add "lastmod before..now" to the current query without any conjunction. That would make us re-index basically all messages. This patch wraps the existing query in parentheses and ANDs it with "lastmod" instead which greatly speeds up the process. Signed-off-by: Robin Dapp <rdapp@modk.org> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: don't reload all message on changeHugo Osvaldo Barrera2024-08-031-12/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | When a notmuch query result was shown and any message changes (e.g.: was marked as read, deleted, flagged, etc) the entire result set was reloaded from disk. This included querying the notmuch for paths for each file individually and then reading headers from each file one by one. If the current view was a query-map with 4000 results, then marking a single message as read resulted in 4000 files being read from disk. When a change is detected in the database, instead of sending an individual MessageInfo event for each message in the result set, send a single DirectoryContents event. The UI code will remove from view any messages that no longer exist, add new ones and request from the worker any data that may be required (this data will be lazy-fetched). This results in a dramatic performance improvement when reading messages from a query-map result. Previously reading a single message would result in about 2 minutes of CPU at 150% (on a i7-13700K). With this patch, the same operation uses less than 5% CPU for less than 2 seconds. Signed-off-by: Hugo Osvaldo Barrera <hugo@whynothugo.nl> Acked-by: Robin Jarry <robin@jarry.cc>
* commands: add :query to create named notmuch dirsJason Cox2024-02-261-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current :cf command can be used to create folders for arbitrary notmuch queries. These folders use the query as their namee. In some cases, though, it's useful to give a more human-readable name. Create a new :query command to allow doing so. The :query command accepts an optional -n flag to specify a name. The remaining arguments are interpreted verbatim as a notmuch query. If no name is specified, the query itself is used as the name. For example, to create a new folder with the full thread of the current message, named by its subject, run the following command: :query -n "{{.SubjectBase}}" thread:"{mid:{{.MessageId}}}" :query could have been implemented as an additional flag to :cf. Giving a name to the created folder would make the smantics of :cf strange, though. For example, to create a named query folder, one would use :cf -n <name> <query>. This syntax feels odd; the name of the folder seems like it ought to be the positional argument of the change folder command. Alternatively, the usage could be :cf -q <query> <name>, but this feels wrong as well: the query, which is provided as a positional parameter when no name is specified, becomes a flag parameter when a name is specified. What's more, both of these potential usages add a notmuch-specific flag to an otherwise general command. Creating a new command feels cleaner. Perhaps the current query functionality of the :cf command could eventually be deprecated to remove the duplicate functionality and keep :cf limited to changing to existing folders. Changelog-added: Create notmuch named queries with the `:query` command. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* log: move package to libRobin Jarry2024-02-141-1/+1
| | | | | | | This has nothing to do at the root of the source tree. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
* notmuch: track database stateTim Culverhouse2023-08-311-12/+47
| | | | | | | | | Track the notmuch database state. When a state change is detected, query if any changes affect the current query then send updates accordingly. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: replace notmuch library with internal bindingsTim Culverhouse2023-08-301-0/+5
| | | | | | | Replace the notmuch library used with our internal bindings. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: add option to provide path for accountKirill Chibisov2023-08-051-1/+3
| | | | | | | | | | Add the "maildir-account-path" account configuration option to select the account relative to the "maildir-store" to have traditional maildir one tab per account behavior with notmuch. Signed-off-by: Kirill Chibisov <contact@kchibisov.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* notmuch: use named loggerRobin Jarry2023-06-121-2/+1
| | | | | | | | Use the worker's logging functions to have all notmuch related messages prefixed by the account name. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* msgstore: fetch message list based on OpenDirectory msgTim Culverhouse2023-04-221-4/+2
| | | | | | | | | | | | | | | Fetching the message list is done in a convoluted way. The UI receives a DirectoryInfo message, which creates a message store. It then receives a second DirectoryInfo (an oddity from the IMAP worker), and this DirectoryInfo is passed to the message store which then requests a fetch of the message list via store.Sort. Use the OpenDirectory done response to tell the message store to fetch messages. This makes the code easier to follow, and does not rely on quirks from the IMAP worker. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: use fswatcher to trigger directory count updateTim Culverhouse2023-03-071-3/+3
| | | | | | | | | | | Use fswatcher to watch the underlying notmuch db to trigger directory updates. Remove unused argument in the handleUpdateDirCounts function. Call this function when listing directories to initialize counts when starting aerc. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Ben Lee-Cohen <ben@lee-cohen.com> Acked-by: Robin Jarry <robin@jarry.cc>
* logging: rename package to logRobin Jarry2022-12-021-2/+2
| | | | | | | | | | Use the same name than the builtin "log" package. That way, we do not risk logging in the wrong place. Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* notmuch: simplify DirectoryInfo emitting logicJulian Pidancet2022-10-271-12/+9
| | | | | | | | | | | | | | | Refactor the code emitting DirectoryInfo messages. Reduce function call indirections by retiring gatherDirectoryInfo(), buildDirInfo() and emitDirectoryInfo(), and replacing them with getDirectoryInfo() (aligning the code with what is done in the maildir worker by the same occasion). Also merge queryFromName(), which no longer needs to be called from different places, in handleOpenDirectory(). Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com> Acked-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* notmuch: make maildir store path configurableJulian Pidancet2022-10-271-11/+13
| | | | | | | | | | | | | | Add the "maildir-store" account configuration option to select the maildir store to associate with the notmuch database. This also allows the previous changes to be backward compatible since not specifying this option will make the backend behave the same as if there were no changes. Fixes: https://todo.sr.ht/~rjarry/aerc/73 Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com> Acked-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* notmuch: add maildir supportJulian Pidancet2022-10-271-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | By associating the notmuch database with a maildir store, we can add the Copy/Move/Delete operations on messages to the notmuch backend. This change assumes that the notmuch database location is also the root of the maildir store. In a previous change, we added the ability to dynamically add and remove message files to the notmuch DB. This change uses this facility to synchronize the database with the filesystem operations on maildir files. While it's still possible to use the query-map file to create virtual folders from notmuch search queries, the sidebar is now loaded with the folders found in the maildir store. With notmuch, two identical but distinct message files can be indexed in the database with the same key. This change takes extra care of only deleting or removing message files from the maildir corresponding to the folder that is currently selected (if any). Implements: https://todo.sr.ht/~rjarry/aerc/88 Fixes: https://todo.sr.ht/~rjarry/aerc/73 Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com> Acked-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* notmuch: fix cursor movement in threaded viewKoni Marti2022-07-311-1/+1
| | | | | | | | | | | | | | | | Set the SkipSort flag when sending directory infos for counting purposes. Without this, the directory infos would trigger a directory fetch which could bring the notmuch threads out of sync with the message list. The notmuch backend sends these directory infos automatically every minute. To reproduce the weird cursor movement in notmuch's threaded view: 1. enter threaded view in notmuch 2. wait 1 min (until the auto directory infos are sent out) 3. move cursor around and notice how it jumps over threads Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* logging: use level-based logger functionsRobin Jarry2022-07-231-1/+3
| | | | | | | | | | | | Do not pass logger objects around anymore. Shuffle some messages to make them consistent with the new logging API. Avoid using %v when a more specific verb exists for the argument types. The loggers are completely disabled (i.e. Sprintf is not even called) by default. They are only enabled when redirecting stdout to a file. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* format: reformat code with go 1.17Robin Jarry2021-12-111-1/+2
| | | | | | | | There was a change in how build tags are formatted. Use this as new reference. Link: https://go.dev/doc/go1.17#gofmt Signed-off-by: Robin Jarry <robin@jarry.cc>
* Add missing notmuch build tagsJeffas2020-02-261-0/+2
|
* notmuch: refresh dirlist in backgroundReto Brunner2020-02-161-1/+14
|
* notmuch: add internal event loopReto Brunner2020-02-161-0/+9