[Pkg-owncloud-commits] [owncloud-client] 135/484: FolderStatusModel: fix getting the size of the folder in the selective sync (#3986)
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:29 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 d657c00b11bf834e64ffd7893022a0a577af52bd
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Fri Oct 23 15:13:15 2015 +0200
FolderStatusModel: fix getting the size of the folder in the selective sync (#3986)
Regressed since d610693af104e98f934878f228f6da57a2380fb2. The problem
is that the _size vector contains the pathToRemove and that it was removed
before.
Reorganize a bit the code so there is only one loop that has still all the
information.
---
src/gui/folderstatusmodel.cpp | 51 +++++++++++++++++++------------------------
1 file changed, 23 insertions(+), 28 deletions(-)
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp
index d0e4905..2df83d6 100644
--- a/src/gui/folderstatusmodel.cpp
+++ b/src/gui/folderstatusmodel.cpp
@@ -509,7 +509,7 @@ void FolderStatusModel::fetchMore(const QModelIndex& parent)
QTimer::singleShot(1000, this, SLOT(slotShowFetchProgress()));
}
-void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
+void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
{
auto job = qobject_cast<LsColJob *>(sender());
Q_ASSERT(job);
@@ -529,46 +529,39 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
parentInfo->_fetching = false;
parentInfo->_fetched = true;
- auto list = list_;
- list.removeFirst(); // remove the parent item
-
QUrl url = parentInfo->_folder->remoteUrl();
QString pathToRemove = url.path();
if (!pathToRemove.endsWith('/'))
pathToRemove += '/';
- // Drop the folder base path and check for excludes.
- QMutableListIterator<QString> it(list);
- while (it.hasNext()) {
- it.next();
- it.value().remove(pathToRemove);
- if (parentInfo->_folder->isFileExcludedRelative(it.value())) {
- it.remove();
- }
- }
-
- beginInsertRows(idx, 0, list.count() - 1);
-
QStringList selectiveSyncBlackList;
if (parentInfo->_checked == Qt::PartiallyChecked) {
selectiveSyncBlackList = parentInfo->_folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList);
}
auto selectiveSyncUndecidedList = parentInfo->_folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList);
- QVarLengthArray<int> undecidedIndexes;
+ QVarLengthArray<int, 10> undecidedIndexes;
+
+ QVector<SubFolderInfo> newSubs;
+ newSubs.reserve(list.size() - 1);
+ for (int i = 1; // skip the parent item (first in the list)
+ i < list.size(); ++i) {
+ const QString &path = list.at(i);
+ auto relativePath = path.mid(pathToRemove.size());
+ if (parentInfo->_folder->isFileExcludedRelative(relativePath)) {
+ continue;
+ }
- int i = 0;
- foreach (QString path, list) {
SubFolderInfo newInfo;
newInfo._folder = parentInfo->_folder;
newInfo._pathIdx = parentInfo->_pathIdx;
- newInfo._pathIdx << i++;
+ newInfo._pathIdx << newSubs.size();
auto size = job ? job->_sizes.value(path) : 0;
newInfo._size = size;
- newInfo._path = path;
- newInfo._name = path.split('/', QString::SkipEmptyParts).last();
+ newInfo._path = relativePath;
+ newInfo._name = relativePath.split('/', QString::SkipEmptyParts).last();
- if (path.isEmpty())
+ if (relativePath.isEmpty())
continue;
if (parentInfo->_checked == Qt::Unchecked) {
@@ -577,25 +570,27 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
newInfo._checked = Qt::Checked;
} else {
foreach(const QString &str , selectiveSyncBlackList) {
- if (str == path || str == QLatin1String("/")) {
+ if (str == relativePath || str == QLatin1String("/")) {
newInfo._checked = Qt::Unchecked;
break;
- } else if (str.startsWith(path)) {
+ } else if (str.startsWith(relativePath)) {
newInfo._checked = Qt::PartiallyChecked;
}
}
}
foreach(const QString &str , selectiveSyncUndecidedList) {
- if (str == path) {
+ if (str == relativePath) {
newInfo._isUndecided = true;
- } else if (str.startsWith(path)) {
+ } else if (str.startsWith(relativePath)) {
undecidedIndexes.append(newInfo._pathIdx.last());
}
}
- parentInfo->_subs.append(newInfo);
+ newSubs.append(newInfo);
}
+ beginInsertRows(idx, 0, newSubs.size() - 1);
+ parentInfo->_subs = std::move(newSubs);
endInsertRows();
for (auto it = undecidedIndexes.begin(); it != undecidedIndexes.end(); ++it) {
--
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