[GODT-797] EXPUNGE waits for APPEND to prevent data loss when Outlook moves from Spam to Inbox

This commit is contained in:
Jakub
2021-01-14 16:39:34 +01:00
parent 2f149eb545
commit 44f8a49b47
6 changed files with 33 additions and 3 deletions

View File

@ -20,6 +20,7 @@ package imap
import (
"errors"
"strings"
"sync"
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
imapquota "github.com/emersion/go-imap-quota"
@ -39,6 +40,8 @@ type imapUser struct {
storeAddress storeAddressProvider
currentAddressLowercase string
appendInProcess sync.WaitGroup
}
// This method should eventually no longer be necessary. Everything should go via store.
@ -238,3 +241,15 @@ func (iu *imapUser) CreateMessageLimit() *uint32 {
upload := uint32(maxUpload)
return &upload
}
func (iu *imapUser) appendStarted() {
iu.appendInProcess.Add(1)
}
func (iu *imapUser) appendFinished() {
iu.appendInProcess.Done()
}
func (iu *imapUser) waitForAppend() {
iu.appendInProcess.Wait()
}