Просмотр исходного кода

shell_integration on Windows: Don't fill the cache with unsolicited statuses #3122

Only keep the status updates if explorer is going to display it.
Jocelyn Turcotte 10 лет назад
Родитель
Сommit
77679790db
1 измененных файлов с 7 добавлено и 4 удалено
  1. 7 4
      shell_integration/windows/OCUtil/RemotePathChecker.cpp

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

@@ -115,13 +115,16 @@ void RemotePathChecker::workerThreadLoop()
                 auto responseStatus = response.substr(statusBegin+1, statusEnd - statusBegin-1);
                 auto responsePath = response.substr(statusEnd+1);
                 auto state = _StrToFileState(responseStatus);
-                auto erased = asked.erase(responsePath);
+                bool wasAsked = asked.erase(responsePath) > 0;
 
                 bool changed = false;
                 {   std::unique_lock<std::mutex> lock(_mutex);
-                    auto &it = _cache[responsePath];
-                    changed = (it != state);
-                    it = state;
+                    bool wasCached = _cache.find(responsePath) != _cache.end();
+                    if (wasAsked || wasCached) {
+                        auto &it = _cache[responsePath];
+                        changed = (it != state);
+                        it = state;
+                    }
                 }
                 if (changed) {
                     SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL);