[Pkg-owncloud-commits] [owncloud-client] 216/484: FolderStatusModel: attempt to detect removed undecided files #3612
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:44 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 49cd53ee447af2dcdc9622cd9d9951db060313be
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Mon Oct 26 15:46:11 2015 +0100
FolderStatusModel: attempt to detect removed undecided files #3612
---
src/gui/folderstatusmodel.cpp | 35 ++++++++++++++++++++++++++++++-----
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp
index 82029ed..fd52a38 100644
--- a/src/gui/folderstatusmodel.cpp
+++ b/src/gui/folderstatusmodel.cpp
@@ -22,6 +22,7 @@
#include <QFileIconProvider>
#include <QVarLengthArray>
+#include <set>
Q_DECLARE_METATYPE(QPersistentModelIndex)
@@ -546,10 +547,16 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
selectiveSyncBlackList = parentInfo->_folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList);
}
auto selectiveSyncUndecidedList = parentInfo->_folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList);
-
QVarLengthArray<int, 10> undecidedIndexes;
-
QVector<SubFolderInfo> newSubs;
+
+ std::set<QString> selectiveSyncUndecidedSet; // not QSet because it's not sorted
+ foreach (const QString &str, selectiveSyncUndecidedList) {
+ if (str.startsWith(parentInfo->_path) || parentInfo->_path == QLatin1String("/")) {
+ selectiveSyncUndecidedSet.insert(str);
+ }
+ }
+
newSubs.reserve(list.size() - 1);
for (int i = 1; // skip the parent item (first in the list)
i < list.size(); ++i) {
@@ -586,11 +593,19 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
}
}
- foreach(const QString &str , selectiveSyncUndecidedList) {
- if (str == relativePath) {
+ auto it = selectiveSyncUndecidedSet.lower_bound(relativePath);
+ if (it != selectiveSyncUndecidedSet.end()) {
+ if (*it == relativePath) {
newInfo._isUndecided = true;
- } else if (str.startsWith(relativePath)) {
+ selectiveSyncUndecidedSet.erase(it);
+ } else if ((*it).startsWith(relativePath)) {
undecidedIndexes.append(newInfo._pathIdx.last());
+
+ // Remove all the items from the selectiveSyncUndecidedSet that starts with this path
+ QString relativePathNext = relativePath;
+ relativePathNext[relativePathNext.length()-1].unicode()++;
+ auto it2 = selectiveSyncUndecidedSet.lower_bound(relativePathNext);
+ selectiveSyncUndecidedSet.erase(it, it2);
}
}
newSubs.append(newInfo);
@@ -603,6 +618,16 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
for (auto it = undecidedIndexes.begin(); it != undecidedIndexes.end(); ++it) {
suggestExpand(idx.child(*it, 0));
}
+
+ /* Try to remove the the undecided lists the items that are not on the server. */
+ auto it = std::remove_if(selectiveSyncUndecidedList.begin(), selectiveSyncUndecidedList.end(),
+ [&](const QString &s) { return selectiveSyncUndecidedSet.count(s); } );
+ if (it != selectiveSyncUndecidedList.end()) {
+ selectiveSyncUndecidedList.erase(it, selectiveSyncUndecidedList.end());
+ parentInfo->_folder->journalDb()->setSelectiveSyncList(
+ SyncJournalDb::SelectiveSyncUndecidedList, selectiveSyncUndecidedList);
+ emit dirtyChanged();
+ }
}
void FolderStatusModel::slotLscolFinishedWithError(QNetworkReply* r)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list