aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/imap/connection.go7
-rw-r--r--internal/util/util.go11
2 files changed, 15 insertions, 3 deletions
diff --git a/internal/imap/connection.go b/internal/imap/connection.go
index e0360bd..88b1496 100644
--- a/internal/imap/connection.go
+++ b/internal/imap/connection.go
@@ -9,6 +9,7 @@ import (
imapClient "github.com/emersion/go-imap/client"
"github.com/Necoro/feed2imap-go/internal/log"
+ "github.com/Necoro/feed2imap-go/internal/util"
)
type connection struct {
@@ -109,10 +110,10 @@ func (conn *connection) ensureFolder(folder Folder) error {
panic("Delimiters do not match")
}
- switch found {
- case 0:
+ switch {
+ case found == 0 || (found == 1 && util.StrContains(mbox.Attributes, imap.NoSelectAttr)):
return conn.createFolder(folder.str)
- case 1:
+ case found == 1:
conn.mailboxes.add(mbox)
return nil
default:
diff --git a/internal/util/util.go b/internal/util/util.go
new file mode 100644
index 0000000..c5472ab
--- /dev/null
+++ b/internal/util/util.go
@@ -0,0 +1,11 @@
+package util
+
+func StrContains(haystack []string, needle string) bool {
+ for _, s := range haystack {
+ if s == needle {
+ return true
+ }
+ }
+
+ return false
+}