From: Jocelyn Turcotte Date: Mon, 9 Jan 2017 13:25:00 +0000 (+0100) Subject: shell/Windows: Fix the view not being updated on StateError X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~888 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e131c142ff7b240378ae895eaac1a9cbea16caf0;p=nextcloud-desktop.git 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. --- diff --git a/shell_integration/windows/OCUtil/RemotePathChecker.cpp b/shell_integration/windows/OCUtil/RemotePathChecker.cpp index 35f918aac..679686ec7 100644 --- a/shell_integration/windows/OCUtil/RemotePathChecker.cpp +++ b/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 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); } }