Browse Source

shell/Windows: Fix the view not being updated on StateError

Since StateError == 0, if this was the status used when the path
isn't in the map already, the view would not be updated since the
new state would be the same as the default-constructed state in the
map. Fix by explicitly inserting in that case, this also avoid aving
to do two lookups in the map when a path already has an entry.
Jocelyn Turcotte 9 years ago
parent
commit
e131c142ff
1 changed files with 14 additions and 7 deletions
  1. 14 7
      shell_integration/windows/OCUtil/RemotePathChecker.cpp

+ 14 - 7
shell_integration/windows/OCUtil/RemotePathChecker.cpp

@@ -120,16 +120,23 @@ void RemotePathChecker::workerThreadLoop()
                 auto state = _StrToFileState(responseStatus);
                 bool wasAsked = asked.erase(responsePath) > 0;
 
-                bool changed = false;
+                bool updateView = false;
                 {   std::unique_lock<std::mutex> lock(_mutex);
-                    bool wasCached = _cache.find(responsePath) != _cache.end();
-                    if (wasAsked || wasCached) {
-                        auto &it = _cache[responsePath];
-                        changed = (it != state);
-                        it = state;
+                    auto it = _cache.find(responsePath);
+                    if (it == _cache.end()) {
+                        // The client only approximates requested files, if the bloom
+                        // filter becomes saturated after navigating multiple directories we'll start getting
+                        // status pushes that we never requested and fill our cache. Ignore those.
+                        if (!wasAsked) {
+                            continue;
+                        }
+                        it = _cache.insert(make_pair(responsePath, StateNone)).first;
                     }
+
+                    updateView = it->second != state;
+                    it->second = state;
                 }
-                if (changed) {
+                if (updateView) {
                     SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL);
                 }
             }