Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix. Take root folder's files size into account when displaying the total size in selective sync dialog. #4532

Merged
merged 1 commit into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/gui/selectivesyncdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ void SelectiveSyncWidget::refreshFolders()
job->setProperties(props);
connect(job, &LsColJob::directoryListingSubfolders,
this, &SelectiveSyncWidget::slotUpdateDirectories);
connect(job, &LsColJob::directoryListingSubfolders,
this, &SelectiveSyncWidget::slotUpdateRootFolderFilesSize);
connect(job, &LsColJob::finishedWithError,
this, &SelectiveSyncWidget::slotLscolFinishedWithError);
connect(job, &LsColJob::directoryListingIterated,
Expand Down Expand Up @@ -288,6 +290,24 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
root->setExpanded(true);
}

void SelectiveSyncWidget::slotUpdateRootFolderFilesSize(const QStringList &subfolders)
{
const auto job = qobject_cast<LsColJob *>(sender());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a check that job is not null


if (!job) {
qWarning() << "slotUpdateRootFolderFilesSize must have a valid sender";
return;
}

_rootFilesSize = 0;

for (auto it = std::cbegin(job->_folderInfos); it != std::cend(job->_folderInfos); ++it) {
if (!subfolders.contains(it.key())) {
_rootFilesSize += it.value().size;
}
}
}

void SelectiveSyncWidget::slotLscolFinishedWithError(QNetworkReply *r)
{
if (r->error() == QNetworkReply::ContentNotFoundError) {
Expand Down Expand Up @@ -454,7 +474,7 @@ qint64 SelectiveSyncWidget::estimatedSize(QTreeWidgetItem *root)
// We did not load from the server so we have no idea how much we will sync from this branch
return -1;
}
return result;
return result + _rootFilesSize;
}


Expand Down
3 changes: 3 additions & 0 deletions src/gui/selectivesyncdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class SelectiveSyncWidget : public QWidget

private slots:
void slotUpdateDirectories(QStringList);
void slotUpdateRootFolderFilesSize(const QStringList &subfolders);
void slotItemExpanded(QTreeWidgetItem *);
void slotItemChanged(QTreeWidgetItem *, int);
void slotLscolFinishedWithError(QNetworkReply *);
Expand All @@ -81,6 +82,8 @@ private slots:
ExcludedFiles _excludedFiles;

QStringList _encryptedPaths;

qint64 _rootFilesSize = 0;
};

/**
Expand Down