-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbonded.go
51 lines (40 loc) · 998 Bytes
/
bonded.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
imap "github.com/emersion/go-imap"
)
type bondedSession struct {
*coms
dst *session
src *session
}
func makeBondedSession(cs *coms, l imap.Logger, dstConf, srcConf sessionConfig) (bondedSession, error) {
bs := bondedSession{
coms: cs,
}
dst, err := newSession(cs, l, dstConf)
if err != nil {
return bs, fmt.Errorf("cannot create destination session: %s", err)
}
bs.dst = dst
src, err := newSession(cs, l, srcConf)
if err != nil {
return bs, fmt.Errorf("cannot create source session: %s", err)
}
bs.src = src
return bs, nil
}
func (s *bondedSession) close() {
if s.dst != nil {
s.dst.close()
}
if s.src != nil {
s.src.close()
}
}
func (s *bondedSession) replicateMailboxes(glblExcl, lclExcl []string) ([]*imapMailboxInfo, error) {
return s.src.replicateMailboxes(s.dst, glblExcl, lclExcl)
}
func (s *bondedSession) replicateMessages(glblExcl, lclExcl []string) error {
return s.src.replicateMessages(s.dst, glblExcl, lclExcl)
}