MCPcopy
hub / github.com/rclone/rclone / receiveChangeNotify

Method receiveChangeNotify

backend/cache/cache.go:819–860  ·  view source on GitHub ↗

receiveChangeNotify is a wrapper to notifications sent from the wrapped FS about changed files

(forgetPath string, entryType fs.EntryType)

Source from the content-addressed store, hash-verified

817
818// receiveChangeNotify is a wrapper to notifications sent from the wrapped FS about changed files
819func (f *Fs) receiveChangeNotify(forgetPath string, entryType fs.EntryType) {
820 if crypt, yes := f.isWrappedByCrypt(); yes {
821 decryptedPath, err := crypt.DecryptFileName(forgetPath)
822 if err == nil {
823 fs.Infof(decryptedPath, "received cache expiry notification")
824 } else {
825 fs.Infof(forgetPath, "received cache expiry notification")
826 }
827 } else {
828 fs.Infof(forgetPath, "received cache expiry notification")
829 }
830 // notify upstreams too (vfs)
831 f.notifyChangeUpstream(forgetPath, entryType)
832
833 var cd *Directory
834 if entryType == fs.EntryObject {
835 co := NewObject(f, forgetPath)
836 err := f.cache.GetObject(co)
837 if err != nil {
838 fs.Debugf(f, "got change notification for non cached entry %v", co)
839 }
840 err = f.cache.ExpireObject(co, true)
841 if err != nil {
842 fs.Debugf(forgetPath, "notify: error expiring '%v': %v", co, err)
843 }
844 cd = NewDirectory(f, cleanPath(path.Dir(co.Remote())))
845 } else {
846 cd = NewDirectory(f, forgetPath)
847 }
848 // we expire the dir
849 err := f.cache.ExpireDir(cd)
850 if err != nil {
851 fs.Debugf(forgetPath, "notify: error expiring '%v': %v", cd, err)
852 } else {
853 fs.Debugf(forgetPath, "notify: expired '%v'", cd)
854 }
855
856 f.notifiedMu.Lock()
857 defer f.notifiedMu.Unlock()
858 f.notifiedRemotes[forgetPath] = true
859 f.notifiedRemotes[cd.Remote()] = true
860}
861
862// notifyChangeUpstreamIfNeeded will check if the wrapped remote doesn't notify on changes
863// or if we use a temp fs

Callers

nothing calls this directly

Calls 15

isWrappedByCryptMethod · 0.95
notifyChangeUpstreamMethod · 0.95
RemoteMethod · 0.95
RemoteMethod · 0.95
InfofFunction · 0.92
DebugfFunction · 0.92
cleanPathFunction · 0.85
ExpireObjectMethod · 0.80
DirMethod · 0.80
ExpireDirMethod · 0.80
NewObjectFunction · 0.70
NewDirectoryFunction · 0.70

Tested by

no test coverage detected