Remove deleted files from cache instead of clearing the whole cache

This commit is contained in:
Stefan Prodan
2018-08-08 12:14:26 +03:00
parent 70b0e92555
commit 2ee11bf6b2
+6 -3
View File
@@ -94,13 +94,16 @@ func (w *Watcher) updateCache() error {
}
}
// clear cache
// remove deleted files from cache
w.Cache.Range(func(key interface{}, value interface{}) bool {
w.Cache.Delete(key)
_, ok := fileMap[key.(string)]
if !ok {
w.Cache.Delete(key)
}
return true
})
// load cache
// sync cache
for k, v := range fileMap {
w.Cache.Store(k, v)
}