cache: always forget parent dir for notifications - for #2117

This commit is contained in:
remusb 2018-03-31 12:44:09 +03:00
parent d45c750f76
commit e42cee5e02

View file

@ -535,28 +535,28 @@ func (f *Fs) receiveChangeNotify(forgetPath string, entryType fs.EntryType) {
if entryType == fs.EntryObject { if entryType == fs.EntryObject {
co := NewObject(f, forgetPath) co := NewObject(f, forgetPath)
err := f.cache.GetObject(co) err := f.cache.GetObject(co)
if err != nil { if err == nil {
fs.Debugf(f, "ignoring change notification for non cached entry %v", co) // expire the entry
return co.CacheTs = time.Now().Add(f.fileAge * -1)
} err = f.cache.AddObject(co)
// expire the entry if err != nil {
co.CacheTs = time.Now().Add(f.fileAge * -1) fs.Debugf(forgetPath, "notify: error expiring '%v': %v", co, err)
err = f.cache.AddObject(co) } else {
if err != nil { fs.Debugf(forgetPath, "notify: expired %v", co)
fs.Errorf(forgetPath, "notify: error expiring '%v': %v", co, err) }
} else { } else {
fs.Debugf(forgetPath, "notify: expired %v", co) fs.Debugf(f, "ignoring change notification for non cached entry %v", co)
} }
cd = NewDirectory(f, cleanPath(path.Dir(co.Remote()))) cd = NewDirectory(f, cleanPath(path.Dir(co.Remote())))
} else { } else {
cd = NewDirectory(f, forgetPath) cd = NewDirectory(f, forgetPath)
// we expire the dir }
err := f.cache.ExpireDir(cd) // we expire the dir
if err != nil { err := f.cache.ExpireDir(cd)
fs.Errorf(forgetPath, "notify: error expiring '%v': %v", cd, err) if err != nil {
} else { fs.Debugf(forgetPath, "notify: error expiring '%v': %v", cd, err)
fs.Debugf(forgetPath, "notify: expired '%v'", cd) } else {
} fs.Debugf(forgetPath, "notify: expired '%v'", cd)
} }
f.notifiedMu.Lock() f.notifiedMu.Lock()