forked from TrueCloudLab/rclone
crypt: implement DirChangeNotify
crypt now implements the DirChangeNotify if the wrapped FS provides it.
This commit is contained in:
parent
5acb6f47e7
commit
ce5b3a531d
1 changed files with 17 additions and 0 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ncw/rclone/fs"
|
"github.com/ncw/rclone/fs"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -129,6 +130,22 @@ func NewFs(name, rpath string) (fs.Fs, error) {
|
||||||
BucketBased: true,
|
BucketBased: true,
|
||||||
CanHaveEmptyDirectories: true,
|
CanHaveEmptyDirectories: true,
|
||||||
}).Fill(f).Mask(wrappedFs)
|
}).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
|
return f, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue