From 40e6d1a8323bc462c842a4aa090adda899ea6952 Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Sat, 10 Jan 2015 22:35:12 +0100 Subject: Do not remove watch-only apps when rescanning app dir --- daemon/appmanager.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/daemon/appmanager.cpp b/daemon/appmanager.cpp index d79c761..9046c5d 100644 --- a/daemon/appmanager.cpp +++ b/daemon/appmanager.cpp @@ -51,8 +51,21 @@ void AppManager::rescan() if (!watchedDirs.isEmpty()) _watcher->removePaths(watchedDirs); QStringList watchedFiles = _watcher->files(); if (!watchedFiles.isEmpty()) _watcher->removePaths(watchedFiles); - _apps.clear(); - _names.clear(); + Q_FOREACH(const AppInfo &appInfo, _apps) { + if (appInfo.isLocal()) { + _apps.remove(appInfo.uuid()); + _names.remove(appInfo.shortName()); + } + } + Q_FOREACH(const QUuid uuid, _names) { + // shouldn't really be needed, but just to make sure + if (_apps.find(uuid) == _apps.end()) { + QString key = _names.key(uuid); + qCWarning(l) << "DESYNC! Got UUID" << uuid << "for app" + << key << "with no app for UUID registered"; + _names.remove(key); + } + } Q_FOREACH(const QString &path, appPaths()) { QDir dir(path); @@ -88,5 +101,5 @@ void AppManager::scanApp(const QString &path) { qCDebug(l) << "scanning app" << path; const AppInfo &info = AppInfo::fromPath(path); - if (info.isLocal()) insertAppInfo(info); + if (info.isValid() && info.isLocal()) insertAppInfo(info); } -- cgit v1.2.3