Skip to content

Commit a9e275e

Browse files
committed
dropbox: correctly limit longpoll to dir
1 parent aecb3e4 commit a9e275e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: internal/dropbox/longpoll.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
// Longpoll signals changes in dir by sending on ch.
1111
func (db Client) Longpoll(ctx context.Context, dir string, ch chan<- struct{}) {
12+
OUTER:
1213
for {
1314
res, err := db.ListFolder(ListFolderParams{
1415
Path: dir,
@@ -42,6 +43,16 @@ func (db Client) Longpoll(ctx context.Context, dir string, ch chan<- struct{}) {
4243
continue
4344
}
4445

45-
ch <- struct{}{}
46+
res = ListFolderResult{HasMore: true, Cursor: cu}
47+
res, err = db.ListFolderContinue(res.Cursor)
48+
if err != nil {
49+
fmt.Fprintln(os.Stderr, "ListFolderContinue:", err)
50+
continue
51+
}
52+
53+
if len(res.Entries) > 0 {
54+
ch <- struct{}{}
55+
}
56+
continue OUTER
4657
}
4758
}

0 commit comments

Comments
 (0)