From ce5b3a531dc754cb5a2c8d53e3a2dbd5b1755a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=B6ller?= Date: Mon, 16 Oct 2017 21:52:12 +0200 Subject: [PATCH] crypt: implement DirChangeNotify crypt now implements the DirChangeNotify if the wrapped FS provides it. --- crypt/crypt.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crypt/crypt.go b/crypt/crypt.go index 9c2cb04ba..ea725b702 100644 --- a/crypt/crypt.go +++ b/crypt/crypt.go @@ -7,6 +7,7 @@ import ( "path" "strconv" "strings" + "time" "github.com/ncw/rclone/fs" "github.com/pkg/errors" @@ -129,6 +130,22 @@ func NewFs(name, rpath string) (fs.Fs, error) { BucketBased: true, CanHaveEmptyDirectories: true, }).Fill(f).Mask(wrappedFs) + + doDirChangeNotify := wrappedFs.Features().DirChangeNotify + if doDirChangeNotify != nil { + f.features.DirChangeNotify = func(notifyFunc func(string), pollInterval time.Duration) chan bool { + wrappedNotifyFunc := func(path string) { + decrypted, err := f.DecryptFileName(path) + if err != nil { + fs.Logf(f, "DirChangeNotify was unable to decrypt %q: %s", path, err) + return + } + notifyFunc(decrypted) + } + return doDirChangeNotify(wrappedNotifyFunc, pollInterval) + } + } + return f, err }