1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 10:33:34 +00:00

fs: update ChangeNotifier interface

This introduces a channel to the ChangeNotify function, which can be
used to update the poll-interval and cleanly exit the polling function.
This commit is contained in:
Fabian Möller
2018-08-25 21:28:57 +02:00
parent 96ce49ec4e
commit 1eec59e091
7 changed files with 103 additions and 53 deletions

View File

@@ -770,9 +770,10 @@ func Run(t *testing.T, opt *Opt) {
err := operations.Mkdir(remote, "dir")
require.NoError(t, err)
pollInterval := make(chan time.Duration)
dirChanges := []string{}
objChanges := []string{}
quitChannel := doChangeNotify(func(x string, e fs.EntryType) {
doChangeNotify(func(x string, e fs.EntryType) {
fs.Debugf(nil, "doChangeNotify(%q, %+v)", x, e)
if strings.HasPrefix(x, file1.Path[:5]) || strings.HasPrefix(x, file2.Path[:5]) {
fs.Debugf(nil, "Ignoring notify for file1 or file2: %q, %v", x, e)
@@ -783,8 +784,9 @@ func Run(t *testing.T, opt *Opt) {
} else if e == fs.EntryObject {
objChanges = append(objChanges, x)
}
}, time.Second)
defer func() { close(quitChannel) }()
}, pollInterval)
defer func() { close(pollInterval) }()
pollInterval <- time.Second
var dirs []string
for _, idx := range []int{1, 3, 2} {