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

Allow event processing between each XML parser run, to improve GUI performance. #6336

Merged
merged 1 commit into from
Jan 29, 2024
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
2 changes: 1 addition & 1 deletion src/gui/editlocallyjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void EditLocallyJob::fetchRemoteFileParentInfo()
return;
}

const auto job = new LsColJob(_accountState->account(), QDir::cleanPath(_folderForFile->remotePathTrailingSlash() + _relPathParent), this);
const auto job = new LsColJob(_accountState->account(), QDir::cleanPath(_folderForFile->remotePathTrailingSlash() + _relPathParent));
const QList<QByteArray> props{QByteArrayLiteral("resourcetype"),
QByteArrayLiteral("getlastmodified"),
QByteArrayLiteral("getetag"),
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderstatusmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ void FolderStatusModel::fetchMore(const QModelIndex &parent)
path += infoPath;
}

auto *job = new LsColJob(_accountState->account(), path, this);
auto *job = new LsColJob(_accountState->account(), path);
info->_fetchingJob = job;
auto props = QList<QByteArray>() << "resourcetype"
<< "http://owncloud.org/ns:size"
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ void FolderWizardRemotePath::slotTypedPathFound(const QStringList &subpaths)

LsColJob *FolderWizardRemotePath::runLsColJob(const QString &path)
{
auto *job = new LsColJob(_account, path, this);
auto *job = new LsColJob(_account, path);
auto props = QList<QByteArray>() << "resourcetype";
if (_account->capabilities().clientSideEncryptionAvailable()) {
props << "http://nextcloud.org/ns:is-encrypted";
Expand Down
4 changes: 2 additions & 2 deletions src/gui/selectivesyncdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
{
_encryptedPaths.clear();

auto *job = new LsColJob(_account, _folderPath, this);
auto *job = new LsColJob(_account, _folderPath);

Check warning on line 110 in src/gui/selectivesyncdialog.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/selectivesyncdialog.cpp:110:11 [cppcoreguidelines-init-variables]

variable 'job' is not initialized
auto props = QList<QByteArray>() << "resourcetype"
<< "http://owncloud.org/ns:size";
if (_account->capabilities().clientSideEncryptionAvailable()) {
Expand Down Expand Up @@ -336,7 +336,7 @@
if (!_folderPath.isEmpty()) {
prefix = _folderPath + QLatin1Char('/');
}
auto *job = new LsColJob(_account, prefix + dir, this);
auto *job = new LsColJob(_account, prefix + dir);

Check warning on line 339 in src/gui/selectivesyncdialog.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/selectivesyncdialog.cpp:339:11 [cppcoreguidelines-init-variables]

variable 'job' is not initialized
job->setProperties(QList<QByteArray>() << "resourcetype"
<< "http://owncloud.org/ns:size");
connect(job, &LsColJob::directoryListingSubfolders,
Expand Down
2 changes: 1 addition & 1 deletion src/gui/shellextensionsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void ShellExtensionsServer::processCustomStateRequest(QLocalSocket *socket, cons
closeSession(socket);
}));

auto *const lsColJob = new LsColJob(folder->accountState()->account(), QDir::cleanPath(folder->remotePath() + lsColJobPath), this);
auto *const lsColJob = new LsColJob(folder->accountState()->account(), QDir::cleanPath(folder->remotePath() + lsColJobPath));
lsColJob->setProperties({QByteArrayLiteral("http://owncloud.org/ns:share-types"), QByteArrayLiteral("http://owncloud.org/ns:permissions")});

const auto folderAlias = customStateRequestInfo.folderAlias;
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
void DiscoverySingleDirectoryJob::start()
{
// Start the actual HTTP job
auto *lsColJob = new LsColJob(_account, _subPath, this);
auto *lsColJob = new LsColJob(_account, _subPath);

Check warning on line 381 in src/libsync/discoveryphase.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/discoveryphase.cpp:381:11 [cppcoreguidelines-init-variables]

variable 'lsColJob' is not initialized

QList<QByteArray> props;
props << "resourcetype"
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/encryptedfoldermetadatahandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void EncryptedFolderMetadataHandler::startFetchMetadata()
void EncryptedFolderMetadataHandler::fetchFolderEncryptedId()
{
qCDebug(lcFetchAndUploadE2eeFolderMetadataJob) << "Folder is encrypted, let's get the Id from it.";
const auto job = new LsColJob(_account, _folderPath, this);
const auto job = new LsColJob(_account, _folderPath);
job->setProperties({"resourcetype", "http://owncloud.org/ns:fileid"});
connect(job, &LsColJob::directoryListingSubfolders, this, &EncryptedFolderMetadataHandler::slotFolderEncryptedIdReceived);
connect(job, &LsColJob::finishedWithError, this, &EncryptedFolderMetadataHandler::slotFolderEncryptedIdError);
Expand Down
17 changes: 13 additions & 4 deletions src/libsync/networkjobs.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/networkjobs.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/networkjobs.cpp

File src/libsync/networkjobs.cpp does not conform to Custom style guidelines. (lines 408)
* Copyright (C) by Klaas Freitag <[email protected]>
* Copyright (C) by Daniel Molkentin <[email protected]>
*
Expand Down Expand Up @@ -317,13 +317,13 @@

/*********************************************************************************************/

LsColJob::LsColJob(AccountPtr account, const QString &path, QObject *parent)
: AbstractNetworkJob(account, path, parent)
LsColJob::LsColJob(AccountPtr account, const QString &path)
: AbstractNetworkJob(account, path)
{
}

LsColJob::LsColJob(AccountPtr account, const QUrl &url, QObject *parent)
: AbstractNetworkJob(account, QString(), parent)
LsColJob::LsColJob(AccountPtr account, const QUrl &url)
: AbstractNetworkJob(account, QString())
, _url(url)
{
}
Expand Down Expand Up @@ -404,6 +404,13 @@
connect(&parser, &LsColXMLParser::finishedWithoutError,
this, &LsColJob::finishedWithoutError);

// bool LsColXMLParser::parse takes a while, let's process some events in attempt to make UI more responsive
// from https://doc.qt.io/qt-5/qcoreapplication.html#processEvents-1
// "You can call this function occasionally when your program is busy doing a long operation (e.g. copying a file)."
// we should not abuse this function, as it affects QObject instances lifetime (when children are getting deleted or when deleteLater is called)
// one reason I had to remove ability for LsColJob to have parent, which, otherwise, leads to a crash later
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);

QString expectedPath = reply()->request().url().path(); // something like "/owncloud/remote.php/dav/folder"
if (!parser.parse(reply()->readAll(), &_folderInfos, expectedPath)) {
// XML parse error
Expand All @@ -414,6 +421,8 @@
emit finishedWithError(reply());
}

this->deleteLater();

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/libsync/networkjobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ class OWNCLOUDSYNC_EXPORT LsColJob : public AbstractNetworkJob
{
Q_OBJECT
public:
explicit LsColJob(AccountPtr account, const QString &path, QObject *parent = nullptr);
explicit LsColJob(AccountPtr account, const QUrl &url, QObject *parent = nullptr);
explicit LsColJob(AccountPtr account, const QString &path);
explicit LsColJob(AccountPtr account, const QUrl &url);
void start() override;
QHash<QString, ExtraFolderInfo> _folderInfos;

Expand Down
2 changes: 1 addition & 1 deletion src/libsync/propagateuploadng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void PropagateUploadFileNG::doStartUpload()
if (progressInfo._valid && progressInfo.isChunked() && progressInfo._modtime == _item->_modtime && progressInfo._size == _item->_size) {
_transferId = progressInfo._transferid;

const auto job = new LsColJob(propagator()->account(), chunkUploadFolderUrl(), this);
const auto job = new LsColJob(propagator()->account(), chunkUploadFolderUrl());
_jobs.append(job);
job->setProperties(QList<QByteArray>() << "resourcetype"
<< "getcontentlength");
Expand Down
Loading