~rockorager/offmap

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH offmap] imap/update: replace delimiters when syncing email

Details
Message ID
<20221130172237.113469-1-tim@timculverhouse.com>
DKIM signature
pass
Download raw message
Patch: +11 -10
The update portion of IMAP selects remote mailboxes based on the mailbox
name in a map. The map is indexed to the local mailbox name only.
Replace delimiters in the local name with the remote's delimiter.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
---
 imap/update.go | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/imap/update.go b/imap/update.go
index 00fef9fe641a..852849ba6215 100644
--- a/imap/update.go
+++ b/imap/update.go
@@ -53,11 +53,12 @@ func (s *Store) ApplyDiff(state *offmap.State, c *offmap.Diff) error {
	// Emails
	conn := s.getConn()
	defer conn.done()
	for dir, emlDiff := range c.Emails {
	for local, emlDiff := range c.Emails {
		// Create emails
		remote := strings.ReplaceAll(local, "/", s.Delimiter())
		// TODO Multiappend?
		for _, eml := range emlDiff.Created {
			_, err := conn.Select(dir, false)
			_, err := conn.Select(remote, false)
			// TODO handle the error
			if err != nil {
				return fmt.Errorf("imap/create email: %v", err)
@@ -67,18 +68,18 @@ func (s *Store) ApplyDiff(state *offmap.State, c *offmap.Diff) error {
			if eml.Date.IsZero() {
				eml.Date = time.Now()
			}
			_, uid, err := client.Append(dir, flags, eml.Date, eml)
			_, uid, err := client.Append(local, flags, eml.Date, eml)
			if err != nil {
				return fmt.Errorf("imap: couldn't create email: %v", err)
			}
			eml.UID = uid
			// Update state
			state.CreateEmail(dir, eml)
			state.CreateEmail(local, eml)
		}

		// add flags
		for flag, emls := range emlDiff.FlagAdded {
			_, err := conn.Select(dir, false)
			_, err := conn.Select(remote, false)
			// TODO handle the error
			if err != nil {
				return fmt.Errorf("imap/add flags: %v", err)
@@ -99,13 +100,13 @@ func (s *Store) ApplyDiff(state *offmap.State, c *offmap.Diff) error {
			}
			// Update state
			for _, eml := range emls {
				state.AddFlag(dir, flag, eml)
				state.AddFlag(local, flag, eml)
			}
		}

		// Remove flags
		for flag, emls := range emlDiff.FlagRemoved {
			_, err := conn.Select(dir, false)
			_, err := conn.Select(remote, false)
			if err != nil {
				return fmt.Errorf("imap/remove flags: %v", err)
			}
@@ -124,13 +125,13 @@ func (s *Store) ApplyDiff(state *offmap.State, c *offmap.Diff) error {
			}
			// Update state
			for _, eml := range emls {
				state.RemoveFlag(dir, flag, eml)
				state.RemoveFlag(local, flag, eml)
			}
		}

		// Delete emails
		if len(emlDiff.Deleted) > 0 {
			_, err := conn.Select(dir, false)
			_, err := conn.Select(remote, false)
			if err != nil {
				return fmt.Errorf("imap/expunge: %v", err)
			}
@@ -149,7 +150,7 @@ func (s *Store) ApplyDiff(state *offmap.State, c *offmap.Diff) error {
			}
			// Update state
			for _, eml := range emlDiff.Deleted {
				state.DeleteEmail(dir, eml)
				state.DeleteEmail(local, eml)
			}
		}
	}
-- 
2.38.1

[offmap/patches/.build.yml] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<COPSZRC34RKV.1IA0O89K3MK9O@cirno2>
In-Reply-To
<20221130172237.113469-1-tim@timculverhouse.com> (view parent)
DKIM signature
missing
Download raw message
offmap/patches/.build.yml: SUCCESS in 1m15s

[imap/update: replace delimiters when syncing email][0] from [Tim Culverhouse][1]

[0]: https://lists.sr.ht/~rockorager/offmap/patches/37249
[1]: tim@timculverhouse.com

✓ #895078 SUCCESS offmap/patches/.build.yml https://builds.sr.ht/~rockorager/job/895078
Details
Message ID
<COPTHH4E0DYI.1TAKCHIWT5V2C@hades.moritz.sh>
In-Reply-To
<20221130172237.113469-1-tim@timculverhouse.com> (view parent)
DKIM signature
pass
Download raw message
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
-- 
Moritz Poldrack
https://moritz.sh
Details
Message ID
<COPTT7K3CD17.3C9KA0OZ2TSN9@spunky>
In-Reply-To
<COPTHH4E0DYI.1TAKCHIWT5V2C@hades.moritz.sh> (view parent)
DKIM signature
pass
Download raw message
On Wed Nov 30, 2022 at 11:47 AM CST, Moritz Poldrack wrote:
> Tested-by: Moritz Poldrack <moritz@poldrack.dev>
> -- 
> Moritz Poldrack
> https://moritz.sh

Applied!

Thanks
Reply to thread Export thread (mbox)