aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir/container.go
Commit message (Collapse)AuthorAgeFilesLines
* maildir: move common maildir code out of workerJulian Pidancet2022-10-271-93/+7
| | | | | | | | | This change moves code that could be common to both notmuch and maildir workers in worker/lib. Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com> Acked-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* maildir: fix maildir folder listingJulian Pidancet2022-10-251-1/+1
| | | | | | | | | | | | | | | Previous change "maildir: hide invalid folders" prevents filepath.Walk from descending into directories that don't contain new/, tmp/ or cur/ because the WalkDirFunc returns filepath.SkipDir. We have to assume that these directories can be the parent of valid maildir folders even if they're not themselves valid maildir folders, so it is a mistake not to recurse into these subfolders. Fix it by returning nil instead of filepath.SkipDir in the WalkDirFunc. Fixes: 150aa0f498b9 ("maildir: hide invalid folders") Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com> Acked-by: Robin Jarry <robin@jarry.cc>
* maildir: hide invalid foldersJulian Pidancet2022-10-031-0/+7
| | | | | | | | | | | | | | | | | The maildir worker currently populates the list of mail folders by listing all the filesystem subdirectories in the maildir directory. Although there's no official specification for maildir subfolders, they should all have cur/ new/ and tmp/ subdirectories to be valid. This patch prevents directories that don't have those subdirectories present on the filesystem from appearing in the account folder list. This is useful for example to prevent ".notmuch" and ".notmuch/xapian" from showing up in the folder list if using notmuch to index emails while using aerc's maildir backend. Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* maildir: remove filename encoded UID when moving messagesTim Culverhouse2022-08-241-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | The built-in maildir.Dir.Move method performs an OS level file rename, which allows for preserving file creation time. Commit c98f70487417 ("move: enable MoveMessages from msgstore") enabled the use of the Move method for maildir. One particular maildir synchronizer (isync/mbsync) encodes the UID within the filename of the email and cannot recover if the UID is preserved during a move. mbsync encodes filenames like so: /path/to/email/{maildir-key},U={uid}:2,S OfflineIMAP encodes the UID within the filename, but also encodes a hash of the originating folder so that it can recover from a move without a rename of the underlying file. OfflineIMAP encodes like so: /path/to/email{maildir-key},U={uid},FMD5={folder-hash}:2,S Remove encoded UIDs of the form `,U={uid}` from filenames to prevent sync issues. Fixes: https://todo.sr.ht/~rjarry/aerc/75 Fixes: c98f70487417 ("move: enable MoveMessages from msgstore") Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* maildir: implement MoveMessages handlingTim Culverhouse2022-08-221-0/+20
| | | | | | | | | | | | | Implement MoveMessages in the maildir worker. go-maildir supports Move operations by default, and is functionally equivalent to a OS-level rename. Creation date of the file is preserved by using Move, which is used by at least one maildir-to-IMAP synchronizer (isync/mbsync). The previous move method of copy-and-delete would reset the creation date of the message, and potentially cause sorting issues in other email clients. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: work nicely with wrapped errors (errorlint)Moritz Poldrack2022-08-041-3/+3
| | | | | | | | Error wrapping as introduced in Go 1.13 adds some additional logic to use for comparing errors and adding information to it. Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: homogenize operations and minor fixes (gocritic)Moritz Poldrack2022-08-041-2/+2
| | | | | | | | | | | | | | | | | | Apply GoDoc comment policy (comments for humans should have a space after the //; machine-readable comments shouldn't) Use strings.ReplaceAll instead of strings.Replace when appropriate Remove if/else chains by replacing them with switches Use short assignment/increment notation Replace single case switches with if statements Combine else and if when appropriate Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: apply new formatting rulesMoritz Poldrack2022-08-011-4/+8
| | | | | | | Run `make fmt`. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* logging: use level-based logger functionsRobin Jarry2022-07-231-4/+2
| | | | | | | | | | | | 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>
* worker/maildir: implement Maildir++ supportAdnan Maolood2022-07-101-3/+30
| | | | | | | See https://www.courier-mta.org/maildir.html#maildircontents Signed-off-by: Adnan Maolood <me@adnano.co> Acked-by: Koni Marti <koni.marti@gmail.com>
* go.mod: change base git urlRobin Jarry2021-11-051-1/+1
| | | | | | | I'm not sure what are the implications but it seems required. Link: https://github.com/golang/go/issues/20883 Signed-off-by: Robin Jarry <robin@jarry.cc>
* maildir: track the recent flag correctlyReto Brunner2021-11-011-9/+31
| | | | | | | | In the maildir worker we manually need to track the Recent flag in order for the notification command etc to work. Push that responsibility to the container, we must make sure to manually add the flag though if one grabs the message info.
* maildir: Provide nicer error message on invalid urlTero Koskinen2020-07-271-3/+18
| | | | | | | | If accounts.conf contains an invalid maildir url, return a nice error instead of panicking. Log a couple of different error cases to provide extra information about the error to the user.
* Allow maildir subdirectoriesGrégoire Delattre2020-05-051-11/+27
|
* maildir: Preserve flags when copying messagesBen Burwell2019-08-081-20/+2
|
* Fix missing format fields in maildir/container.goDrew DeVault2019-07-131-2/+2
|
* Implement maildir copyBen Burwell2019-07-121-0/+38
| | | | | Create a delivery in the destination directory with the content of the source message.
* Add maildir backend workerBen Burwell2019-07-121-0/+105
Add the initial implementation of a backend for Maildir accounts. Much of the functionality required is implemented in the go-message and go-maildir libraries, so we use them as much as possible. The maildir worker hooks into a new maildir:// URL scheme in the accounts.conf file which points to a container of several maildir directories. From there, the OpenDirectory, FetchDirectoryContents, etc messages work on subdirectories. This is implemented as a Container struct which handles mapping between the symbolic email folder names and UIDs to the concrete directories and file names.