Skip to content

Commit

Permalink
SelectiveSync: Apply excludes owncloud#3876
Browse files Browse the repository at this point in the history
  • Loading branch information
ckamm committed Oct 2, 2015
1 parent 7d18866 commit d610693
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
19 changes: 14 additions & 5 deletions src/gui/folderstatusmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,22 +496,32 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
return;
}

auto list = list_;
list.removeFirst(); // remove the parent item

if (parentInfo->_hasError) {
beginRemoveRows(idx, 0 ,0);
parentInfo->_hasError = false;
endRemoveRows();
}

beginInsertRows(idx, 0, list.count() - 1);
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();
if (parentInfo->_folder->isFileExcluded(it.value())) {
it.remove();
}
it.value().remove(pathToRemove);
}

beginInsertRows(idx, 0, list.count() - 1);

parentInfo->_fetched = true;
parentInfo->_fetching = false;

Expand All @@ -531,7 +541,6 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
newInfo._pathIdx << i++;
auto size = job ? job->_sizes.value(path) : 0;
newInfo._size = size;
path.remove(pathToRemove);
newInfo._path = path;
newInfo._name = path.split('/', QString::SkipEmptyParts).last();

Expand Down
18 changes: 17 additions & 1 deletion src/gui/selectivesyncdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void SelectiveSyncTreeView::recursiveInsert(QTreeWidgetItem* parent, QStringList
}
}

void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list)
void SelectiveSyncTreeView::slotUpdateDirectories(QStringList list)
{
auto job = qobject_cast<LsColJob *>(sender());

Expand All @@ -174,6 +174,22 @@ void SelectiveSyncTreeView::slotUpdateDirectories(const QStringList&list)
if (!_folderPath.isEmpty())
pathToRemove.append('/');

// Check for excludes.
//
// We would like to use Folder::isFileExcluded, but the folder doesn't
// exist yet. So we just create one temporarily...
FolderDefinition def;
def.localPath = pathToRemove;
def.ignoreHiddenFiles = FolderMan::instance()->ignoreHiddenFiles();
Folder f(def);
QMutableListIterator<QString> it(list);
while (it.hasNext()) {
it.next();
if (f.isFileExcluded(it.value())) {
it.remove();
}
}

// Since / cannot be in the blacklist, expand it to the actual
// list of top-level folders as soon as possible.
if (_oldBlackList == QStringList("/")) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/selectivesyncdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SelectiveSyncTreeView : public QTreeWidget {

QSize sizeHint() const Q_DECL_OVERRIDE;
private slots:
void slotUpdateDirectories(const QStringList &);
void slotUpdateDirectories(QStringList);
void slotItemExpanded(QTreeWidgetItem *);
void slotItemChanged(QTreeWidgetItem*,int);
void slotLscolFinishedWithError(QNetworkReply*);
Expand Down

0 comments on commit d610693

Please sign in to comment.