aboutsummaryrefslogtreecommitdiff
path: root/internal/imap
diff options
context:
space:
mode:
Diffstat (limited to 'internal/imap')
-rw-r--r--internal/imap/connection.go1
-rw-r--r--internal/imap/folder.go10
-rw-r--r--internal/imap/mailboxes.go8
3 files changed, 18 insertions, 1 deletions
diff --git a/internal/imap/connection.go b/internal/imap/connection.go
index e8d4da2..213171e 100644
--- a/internal/imap/connection.go
+++ b/internal/imap/connection.go
@@ -225,6 +225,7 @@ func (conn *connection) replace(folder Folder, header, value, newContent string,
func (conn *connection) searchHeader(header, value string) ([]uint32, error) {
criteria := imap.NewSearchCriteria()
criteria.Header.Set(header, value)
+ criteria.WithoutFlags = []string{imap.DeletedFlag}
ids, err := conn.search(criteria)
if err != nil {
return nil, fmt.Errorf("searching for header %q=%q: %w", header, value, err)
diff --git a/internal/imap/folder.go b/internal/imap/folder.go
index e845862..6353bb3 100644
--- a/internal/imap/folder.go
+++ b/internal/imap/folder.go
@@ -21,9 +21,17 @@ func (f Folder) Append(other Folder) Folder {
}
}
+func buildFolderName(path []string, delimiter string) (name string) {
+ name = strings.Join(path, delimiter)
+ if delimiter != "" {
+ name = strings.Trim(name, delimiter[0:1])
+ }
+ return
+}
+
func (cl *Client) folderName(path []string) Folder {
return Folder{
- strings.Join(path, cl.delimiter),
+ buildFolderName(path, cl.delimiter),
cl.delimiter,
}
}
diff --git a/internal/imap/mailboxes.go b/internal/imap/mailboxes.go
index f1dc6c6..25bf087 100644
--- a/internal/imap/mailboxes.go
+++ b/internal/imap/mailboxes.go
@@ -26,6 +26,14 @@ func (mbs *mailboxes) unlocking(elem Folder) {
func (mbs *mailboxes) locking(elem Folder) bool {
mbs.mu.Lock()
+
+ // check again, if the folder has been created in the meantime
+ _, ok := mbs.mb[elem.str]
+ if ok {
+ mbs.mu.Unlock()
+ return true
+ }
+
ch, ok := mbs.changeLocks[elem.str]
if !ok {
ch = make(chan struct{})