From 556d21c549178733201246885161525a80119f4b Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 7 Feb 2024 22:01:00 +0100 Subject: [PATCH 1/6] Show details of the syncing progress in the settings dialog. Before it was only shown in the tooltip. Signed-off-by: Camila Ayres --- src/gui/folderstatusdelegate.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gui/folderstatusdelegate.cpp b/src/gui/folderstatusdelegate.cpp index b356a3dd32b83..7957b55a0fd23 100644 --- a/src/gui/folderstatusdelegate.cpp +++ b/src/gui/folderstatusdelegate.cpp @@ -332,6 +332,17 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & painter->setFont(progressFont); painter->drawText(QStyle::visualRect(option.direction, option.rect, overallProgressRect), Qt::AlignLeft | Qt::AlignVCenter, overallString); + + // More detailed sync progress + QRect itemStringRect; + itemStringRect.setTop(overallProgressRect.bottom()); + itemStringRect.setHeight(fileNameTextHeight); + itemStringRect.setLeft(overallProgressRect.left()); + itemStringRect.setWidth(overallProgressRect.width()); + painter->setFont(progressFont); + + painter->drawText(QStyle::visualRect(option.direction, option.rect, itemStringRect), Qt::AlignLeft | Qt::AlignVCenter, itemString); + painter->restore(); } From 4f365ec721a9a5ccb9a118904805ccdd7c24c217 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Fri, 9 Feb 2024 20:48:44 +0100 Subject: [PATCH 2/6] Add logs. Signed-off-by: Camila Ayres --- src/gui/accountsettings.cpp | 6 +++++- src/gui/application.cpp | 1 + src/gui/connectionvalidator.cpp | 2 ++ src/gui/folder.cpp | 2 ++ src/gui/folderman.cpp | 6 +++++- src/gui/owncloudgui.cpp | 1 + src/gui/systray.cpp | 2 ++ src/gui/tray/usermodel.cpp | 3 +++ src/libsync/discovery.cpp | 2 ++ src/libsync/discoveryphase.cpp | 7 +++++++ src/libsync/networkjobs.cpp | 6 ++++-- src/libsync/propagateremotemkdir.cpp | 1 + src/libsync/syncengine.cpp | 1 + 13 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 719f85704f8d4..761a2403331bc 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -672,6 +672,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos) if (!folderPaused) { ac = menu->addAction(tr("Force sync now")); if (folder && folder->isSyncRunning()) { + qCWarning(lcAccountSettings) << "=> Restart syncing for" << selectedFolderAlias(); ac->setText(tr("Restart sync")); } ac->setEnabled(folderConnected); @@ -1139,6 +1140,7 @@ void AccountSettings::showConnectionLabel(const QString &message, QStringList er void AccountSettings::slotEnableCurrentFolder(bool terminate) { + qCWarning(lcAccountSettings) << "=> User!! resuming or pausing sync: terminate value is" << terminate; const auto alias = selectedFolderAlias(); if (!alias.isEmpty()) { @@ -1195,8 +1197,9 @@ void AccountSettings::slotScheduleCurrentFolder() void AccountSettings::slotScheduleCurrentFolderForceRemoteDiscovery() { - const auto folderMan = FolderMan::instance(); + const auto folderMan = FolderMan::instance(); if (auto folder = folderMan->folder(selectedFolderAlias())) { + qCWarning(lcAccountSettings) << "=> Schedule current folder" << selectedFolderAlias() << "RemoteDiscovery"; folder->slotWipeErrorBlacklist(); folder->journalDb()->forceRemoteDiscoveryNextSync(); folderMan->scheduleFolder(folder); @@ -1207,6 +1210,7 @@ void AccountSettings::slotForceSyncCurrentFolder() { FolderMan *folderMan = FolderMan::instance(); auto selectedFolder = folderMan->folder(selectedFolderAlias()); + qCWarning(lcAccountSettings) << "=> Force syncing for" << selectedFolderAlias(); folderMan->forceSyncForFolder(selectedFolder); } diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 48fb06682f109..b2963e45f1b77 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -598,6 +598,7 @@ void Application::slotAccountStateAdded(AccountState *accountState) void Application::slotCleanup() { + qCWarning(lcApplication) << "=> User!! Application is about to quite/close!!"; AccountManager::instance()->save(); FolderMan::instance()->unloadAndDeleteAllFolders(); diff --git a/src/gui/connectionvalidator.cpp b/src/gui/connectionvalidator.cpp index 9cc24de4a7521..12efa80ca89fc 100644 --- a/src/gui/connectionvalidator.cpp +++ b/src/gui/connectionvalidator.cpp @@ -207,6 +207,8 @@ void ConnectionValidator::slotAuthFailed(QNetworkReply *reply) auto job = qobject_cast(sender()); Status stat = Timeout; + qCWarning(lcConnectionValidator) << "=> reply->error():" << reply->error() << "- job->errorString():" << job->errorString(); + if (reply->error() == QNetworkReply::SslHandshakeFailedError) { _errors << job->errorStringParsingBody(); stat = SslError; diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index d7c5fbac54bc9..59233cc1993f7 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -361,6 +361,8 @@ void Folder::etagRetrieved(const QByteArray &etag, const QDateTime &tp) { // re-enable sync if it was disabled because network was down FolderMan::instance()->setSyncEnabled(true); + qCInfo(lcFolder) << "=> Etag retrieved: last:" << _lastEtag << ", received:" << etag; + qCInfo(lcFolder) << "=> For folder:" << _canonicalLocalPath; if (_lastEtag != etag) { qCInfo(lcFolder) << "Compare etag with previous etag: last:" << _lastEtag << ", received:" << etag << "-> CHANGED"; diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index ffced3a51ccc0..46ee9e5cb9fcf 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -654,6 +654,7 @@ void FolderMan::forceSyncForFolder(Folder *folder) // Terminate and reschedule any running sync for (const auto folderInMap : map()) { if (folderInMap->isSyncRunning()) { + qCWarning(lcFolderMan) << "=> User!! Terminating syncing for" << folderInMap->path(); folderInMap->slotTerminateSync(); scheduleFolder(folderInMap); } @@ -679,7 +680,7 @@ void FolderMan::removeE2eFiles(const AccountPtr &account) const void FolderMan::slotScheduleAppRestart() { _appRestartRequired = true; - qCInfo(lcFolderMan) << "Application restart requested!"; + qCInfo(lcFolderMan) << "=> Application restart requested!"; } void FolderMan::slotSyncOnceFileUnlocks(const QString &path) @@ -1339,6 +1340,7 @@ void FolderMan::removeFolder(Folder *f) const bool currentlyRunning = f->isSyncRunning(); if (currentlyRunning) { // abort the sync now + qCWarning(lcFolderMan) << "=> User?? Abort syncing for" << f->path(); f->slotTerminateSync(); } @@ -1929,6 +1931,8 @@ Folder *FolderMan::currentSyncFolder() const void FolderMan::restartApplication() { + qCInfo(lcFolderMan) << "Restarting application NOW!!"; + if (Utility::isLinux()) { // restart: qCInfo(lcFolderMan) << "Restarting application NOW, PID" << qApp->applicationPid() << "is ending."; diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index c14b5125a0861..5e095ddb7f9ba 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -600,6 +600,7 @@ void ownCloudGui::slotShutdown() { // explicitly close windows. This is somewhat of a hack to ensure // that saving the geometries happens ASAP during a OS shutdown + qCWarning(lcApplication) << "=> Shutting down!!"; // those do delete on close if (!_settingsDialog.isNull()) diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index d65258e1fa468..a7b4eca9f28c9 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -452,11 +452,13 @@ void Systray::slotUpdateSyncPausedState() void Systray::slotUnpauseAllFolders() { + qCWarning(lcSystray) << "=> User!! Resume/unpause syncing all folders!!"; setPauseOnAllFoldersHelper(false); } void Systray::slotPauseAllFolders() { + qCWarning(lcSystray) << "=> User!! Pause syncing all folders!!"; setPauseOnAllFoldersHelper(true); } diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 7cb3b08e7afa7..e2f2311f81fd6 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -36,6 +36,8 @@ constexpr qint64 activityDefaultExpirationTimeMsecs = 1000 * 60 * 10; } namespace OCC { + +Q_LOGGING_CATEGORY(lcUserModel, "nextcloud.gui.usermodel", QtInfoMsg) TrayFolderInfo::TrayFolderInfo(const QString &name, const QString &parentPath, const QString &fullPath, FolderType folderType) : _name(name) @@ -1099,6 +1101,7 @@ void User::slotSendReplyMessage(const int activityIndex, const QString &token, c void User::forceSyncNow() const { + qCWarning(lcUserModel) << "=> Force sync now for" << getFolder()->path(); FolderMan::instance()->forceSyncForFolder(getFolder()); } diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index ccfb0c25f982e..a8af29ba452f6 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -2120,6 +2120,8 @@ void ProcessDirectoryJob::startAsyncLocalQuery() QString localPath = _discoveryData->_localDir + _currentFolder._local; auto localJob = new DiscoverySingleLocalDirectoryJob(_discoveryData->_account, localPath, _discoveryData->_syncOptions._vfs.data()); + qCWarning(lcDisco) << "=> ProcessDirectoryJob::startAsyncLocalQuery: localPath:" << localPath; + _discoveryData->_currentlyActiveJobs++; _pendingAsyncJobs++; diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index 33516635d9384..d74b31a33dda4 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -80,6 +80,7 @@ void DiscoveryPhase::checkFolderSizeLimit(const QString &path, const std::functi << "http://owncloud.org/ns:size"); connect(propfindJob, &PropfindJob::finishedWithError, this, [=] { + qCWarning(lcDiscovery) << "=> propfindJob->reply()->error():" << propfindJob->reply()->error() << "- propfindJob->reply()->errorString():" << propfindJob->reply()->errorString(); return completionCallback(false); }); connect(propfindJob, &PropfindJob::result, this, [=](const QVariantMap &values) { @@ -228,8 +229,10 @@ void DiscoveryPhase::enqueueDirectoryToDelete(const QString &path, ProcessDirect void DiscoveryPhase::startJob(ProcessDirectoryJob *job) { ENFORCE(!_currentRootJob); + qCWarning(lcDiscovery) << "=> DiscoveryPhase::startJob for:" << job->_dirItem; connect(this, &DiscoveryPhase::itemDiscovered, this, &DiscoveryPhase::slotItemDiscovered, Qt::UniqueConnection); connect(job, &ProcessDirectoryJob::finished, this, [this, job] { + qCWarning(lcDiscovery) << "=> ProcessDirectoryJob::finished for" << job->_dirItem; ENFORCE(_currentRootJob == sender()); _currentRootJob = nullptr; if (job->_dirItem) @@ -276,6 +279,10 @@ void DiscoveryPhase::scheduleMoreJobs() void DiscoveryPhase::slotItemDiscovered(const OCC::SyncFileItemPtr &item) { + qCWarning(lcDiscovery) << "=> DiscoveryPhase::slotItemDiscovered:" + << "| item->_file:" << item->_file + << "| item->_direction:" << item->_direction + << "| item->_instruction:" << item->_instruction; if (item->_instruction == CSYNC_INSTRUCTION_ERROR && item->_direction == SyncFileItem::Up) { _hasUploadErrorItems = true; } diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 700afb41741f5..a57423068ee49 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -669,6 +669,7 @@ bool PropfindJob::finished() if (!domDocument.setContent(reply(), true, &errorMsg, &errorLine, &errorColumn)) { qCWarning(lcPropfindJob) << "XML parser error: " << errorMsg << errorLine << errorColumn; + qCWarning(lcPropfindJob) << "=> reply()->error():" << reply()->error() << "- reply()->errorString():" << reply()->errorString(); emit finishedWithError(reply()); } else { @@ -679,6 +680,7 @@ bool PropfindJob::finished() } else { qCWarning(lcPropfindJob) << "*not* successful, http result code is" << http_result_code << (http_result_code == 302 ? reply()->header(QNetworkRequest::LocationHeader).toString() : QLatin1String("")); + qCWarning(lcPropfindJob) << "=> reply()->error():" << reply()->error() << "- reply()->errorString():" << reply()->errorString(); emit finishedWithError(reply()); } @@ -1270,8 +1272,8 @@ void fetchPrivateLinkUrl(AccountPtr account, const QString &remotePath, targetFun(oldUrl); } }); - QObject::connect(job, &PropfindJob::finishedWithError, target, [=](QNetworkReply *) { - targetFun(oldUrl); + QObject::connect(job, &PropfindJob::finishedWithError, target, [=](QNetworkReply * reply) { + qCWarning(lcPropfindJob) << "=> reply->error():" << reply->error() << "- job->errorString():" << job->errorString(); }); job->start(); } diff --git a/src/libsync/propagateremotemkdir.cpp b/src/libsync/propagateremotemkdir.cpp index e301beed5a723..e03daf7a2171f 100644 --- a/src/libsync/propagateremotemkdir.cpp +++ b/src/libsync/propagateremotemkdir.cpp @@ -175,6 +175,7 @@ void PropagateRemoteMkdir::finalizeMkColJob(QNetworkReply::NetworkError err, con }); connect(propfindJob, &PropfindJob::finishedWithError, this, [this] (QNetworkReply *reply) { const auto err = reply ? reply->error() : QNetworkReply::NetworkError::UnknownNetworkError; + qCWarning(lcPropagateRemoteMkdir) << "=> reply->error():" << reply->error() << "- propfindJob->errorString():" << reply->errorString(); propagator()->_activeJobList.removeOne(this); done(SyncFileItem::NormalError, {}, errorCategoryFromNetworkError(err)); }); diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 8f8dcecec31ca..553073d4aec82 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -683,6 +683,7 @@ void SyncEngine::startSync() connect(_discoveryPhase.data(), &DiscoveryPhase::existingFolderNowBig, this, &SyncEngine::existingFolderNowBig); connect(_discoveryPhase.data(), &DiscoveryPhase::fatalError, this, [this](const QString &errorString, ErrorCategory errorCategory) { Q_EMIT syncError(errorString, errorCategory); + qCWarning(lcEngine) << "=> SyncEngine DiscoveryPhase::fatalError emitted:" << errorString; finalize(false); }); connect(_discoveryPhase.data(), &DiscoveryPhase::finished, this, &SyncEngine::slotDiscoveryFinished); From 2f1b7e9f73c4a4ac40fd9a19bdf3f0349313aad7 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 7 May 2024 18:31:02 +0200 Subject: [PATCH 3/6] only compute checksum of a local file that is not a virtual one should avoid triggering implicit hydration from within the desktop client triggering an implicit hydration on our own is strictly forbidden as that is causing issues like deadlock and failed hydration attempts Signed-off-by: Matthieu Gallien --- src/libsync/propagatedownload.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 1faf04410a2d7..e5ecec322a970 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -1132,7 +1132,8 @@ void PropagateDownloadFile::contentChecksumComputed(const QByteArray &checksumTy SyncJournalFileRecord record; if (_item->_instruction != CSYNC_INSTRUCTION_CONFLICT && FileSystem::fileExists(localFilePath) && (propagator()->_journal->getFileRecord(_item->_file, &record) && record.isValid()) - && (record._modtime == _item->_modtime && record._etag != _item->_etag)) { + && (record._modtime == _item->_modtime && record._etag != _item->_etag) + && _item->_type == ItemTypeFile) { const auto computeChecksum = new ComputeChecksum(this); computeChecksum->setChecksumType(checksumType); connect(computeChecksum, &ComputeChecksum::done, this, &PropagateDownloadFile::localFileContentChecksumComputed); From 3a40ef699195ebaec1a35d9f43164d979d154ea7 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Wed, 12 Jun 2024 15:32:01 +0200 Subject: [PATCH 4/6] Add logs. Signed-off-by: Camila Ayres --- src/libsync/propagatedownload.cpp | 2 +- src/libsync/vfs/cfapi/cfapiwrapper.cpp | 28 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index e5ecec322a970..3212396a9db44 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -329,7 +329,7 @@ void GETFileJob::slotReadyRead() } if (reply()->isFinished() && (reply()->bytesAvailable() == 0 || !_saveBodyToFile)) { - qCDebug(lcGetJob) << "Actually finished!"; + qCDebug(lcGetJob) << "Get file job finished bytesAvailable/_saveBodyToFile:" << reply()->bytesAvailable() << "/" << _saveBodyToFile ; if (_bandwidthManager) { _bandwidthManager->unregisterDownloadJob(this); } diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index 8b16887956944..57707af4cf1e5 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -133,6 +133,9 @@ void cfApiSendTransferInfo(const CF_CONNECTION_KEY &connectionKey, const CF_TRAN void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const CF_CALLBACK_PARAMETERS *callbackParameters) { qDebug(lcCfApiWrapper) << "Fetch data callback called. File size:" << callbackInfo->FileSize.QuadPart; + qDebug(lcCfApiWrapper) << "Fetch data requested by proccess id:" << callbackInfo->ProcessInfo->ProcessId; + qDebug(lcCfApiWrapper) << "Fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + const auto sendTransferError = [=] { cfApiSendTransferInfo(callbackInfo->ConnectionKey, callbackInfo->TransferKey, @@ -158,6 +161,8 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath)); const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); + qCDebug(lcCfApiWrapper) << "Request hydration for" << path << requestId; + const auto invokeResult = QMetaObject::invokeMethod(vfs, [=] { vfs->requestHydration(requestId, path); }, Qt::QueuedConnection); if (!invokeResult) { qCCritical(lcCfApiWrapper) << "Failed to trigger hydration for" << path << requestId; @@ -165,26 +170,33 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const return; } + qCDebug(lcCfApiWrapper) << "Successfully triggered hydration for" << path << requestId; + // Block and wait for vfs to signal back the hydration is ready bool hydrationRequestResult = false; QEventLoop loop; QObject::connect(vfs, &OCC::VfsCfApi::hydrationRequestReady, &loop, [&](const QString &id) { if (requestId == id) { hydrationRequestResult = true; + qCDebug(lcCfApiWrapper) << "Hydration request ready for" << path << requestId; loop.quit(); } }); QObject::connect(vfs, &OCC::VfsCfApi::hydrationRequestFailed, &loop, [&](const QString &id) { if (requestId == id) { hydrationRequestResult = false; + qCDebug(lcCfApiWrapper) << "Hydration request failed for" << path << requestId; loop.quit(); } }); + + qCDebug(lcCfApiWrapper) << "Starting event loop 1"; loop.exec(); - QObject::disconnect(vfs, nullptr, &loop, nullptr); - qCInfo(lcCfApiWrapper) << "VFS replied for hydration of" << path << requestId << "status was:" << hydrationRequestResult; + QObject::disconnect(vfs, nullptr, &loop, nullptr); // Ensure we properly cancel hydration on server errors + qCInfo(lcCfApiWrapper) << "VFS replied for hydration of" << path << requestId << "status was:" << hydrationRequestResult; if (!hydrationRequestResult) { + qCCritical(lcCfApiWrapper) << "Failed to trigger hydration for" << path << requestId; sendTransferError(); return; } @@ -212,6 +224,7 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const auto hydrationRequestCancelled = false; QObject::connect(&signalSocket, &QLocalSocket::readyRead, &loop, [&] { hydrationRequestCancelled = true; + qCCritical(lcCfApiWrapper) << "Hydration canceled for " << path << requestId; }); // CFAPI expects sent blocks to be of a multiple of a block size. @@ -223,17 +236,25 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const const auto alignAndSendData = [&](const QByteArray &receivedData) { QByteArray data = protrudingData + receivedData; + qCWarning(lcCfApiWrapper) << "protrudingData + receivedData:" << data; protrudingData.clear(); if (data.size() < cfapiBlockSize) { protrudingData = data; + qCWarning(lcCfApiWrapper) << "protrudingData:" << protrudingData; + sendTransferInfo(data, dataOffset); + dataOffset += data.size(); return; } const auto protudingSize = data.size() % cfapiBlockSize; + qCWarning(lcCfApiWrapper) << "protudingSize:" << protudingSize; protrudingData = data.right(protudingSize); + qCWarning(lcCfApiWrapper) << "data.right(protudingSize):" << protrudingData; data.chop(protudingSize); - + qCWarning(lcCfApiWrapper) << "data.chop(protudingSize)" << data; + qCWarning(lcCfApiWrapper) << "sendTransferInfo(data:" << data << ", dataOffset:" << dataOffset << ")"; sendTransferInfo(data, dataOffset); dataOffset += data.size(); + qCWarning(lcCfApiWrapper) << "dataOffset:" << dataOffset; }; QObject::connect(&socket, &QLocalSocket::readyRead, &loop, [&] { @@ -260,6 +281,7 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const } }); + qCDebug(lcCfApiWrapper) << "Starting event loop 2"; loop.exec(); if (!hydrationRequestCancelled && !protrudingData.isEmpty()) { From da80a4f5bd93dff446d3ddac605adde2a3796b36 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Thu, 13 Jun 2024 19:57:27 +0200 Subject: [PATCH 5/6] Add new cfapi callbacks for logging. Signed-off-by: Camila Ayres --- src/libsync/vfs/cfapi/cfapiwrapper.cpp | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index 57707af4cf1e5..6138146532a59 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -373,9 +373,57 @@ void CALLBACK cfApiCancelFetchData(const CF_CALLBACK_INFO *callbackInfo, const C } } +void CALLBACK cfApiNotifyFileOpenCompletion(const CF_CALLBACK_INFO *callbackInfo, const CF_CALLBACK_PARAMETERS * /*callbackParameters*/) +{ + const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath)); + + auto vfs = reinterpret_cast(callbackInfo->CallbackContext); + Q_ASSERT(vfs->metaObject()->className() == QByteArrayLiteral("OCC::VfsCfApi")); + const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); + + qCDebug(lcCfApiWrapper) << "Open file completion:" << path << requestId; +} + +void CALLBACK cfApiValidateData(const CF_CALLBACK_INFO *callbackInfo, const CF_CALLBACK_PARAMETERS * /*callbackParameters*/) +{ + const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath)); + + auto vfs = reinterpret_cast(callbackInfo->CallbackContext); + Q_ASSERT(vfs->metaObject()->className() == QByteArrayLiteral("OCC::VfsCfApi")); + const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); + + qCDebug(lcCfApiWrapper) << "Validate data:" << path << requestId; +} + +void CALLBACK cfApiCancelFetchPlaceHolders(const CF_CALLBACK_INFO *callbackInfo, const CF_CALLBACK_PARAMETERS * /*callbackParameters*/) +{ + const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath)); + + auto vfs = reinterpret_cast(callbackInfo->CallbackContext); + Q_ASSERT(vfs->metaObject()->className() == QByteArrayLiteral("OCC::VfsCfApi")); + const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); + + qCDebug(lcCfApiWrapper) << "Cancel fetch placeholder:" << path << requestId; +} + +void CALLBACK cfApiNotifyFileCloseCompletion(const CF_CALLBACK_INFO *callbackInfo, const CF_CALLBACK_PARAMETERS * /*callbackParameters*/) +{ + const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath)); + + auto vfs = reinterpret_cast(callbackInfo->CallbackContext); + Q_ASSERT(vfs->metaObject()->className() == QByteArrayLiteral("OCC::VfsCfApi")); + const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); + + qCDebug(lcCfApiWrapper) << "Close file completion:" << path << requestId; +} + CF_CALLBACK_REGISTRATION cfApiCallbacks[] = { { CF_CALLBACK_TYPE_FETCH_DATA, cfApiFetchDataCallback }, { CF_CALLBACK_TYPE_CANCEL_FETCH_DATA, cfApiCancelFetchData }, + { CF_CALLBACK_TYPE_NOTIFY_FILE_OPEN_COMPLETION, cfApiNotifyFileOpenCompletion }, + { CF_CALLBACK_TYPE_NOTIFY_FILE_CLOSE_COMPLETION, cfApiNotifyFileCloseCompletion }, + { CF_CALLBACK_TYPE_VALIDATE_DATA, cfApiValidateData }, + { CF_CALLBACK_TYPE_CANCEL_FETCH_PLACEHOLDERS, cfApiCancelFetchPlaceHolders }, CF_CALLBACK_REGISTRATION_END }; From d678a9a40ff4c2f7f3c0cdf55d4a4050d2cea746 Mon Sep 17 00:00:00 2001 From: Camila San Date: Thu, 13 Jun 2024 19:59:49 +0200 Subject: [PATCH 6/6] Start reporting progress before hydration starts. Signed-off-by: Camila Ayres --- src/libsync/vfs/cfapi/cfapiwrapper.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index 6138146532a59..9ab3a44f89dd4 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -156,6 +156,17 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const callbackInfo->FileSize.QuadPart); }; + // The operation that was requested is pending completion. + const auto pendingTransferInfo = [=] { + cfApiSendTransferInfo(callbackInfo->ConnectionKey, + callbackInfo->TransferKey, + STATUS_PENDING, + nullptr, + callbackParameters->FetchData.RequiredFileOffset.QuadPart, + callbackParameters->FetchData.RequiredLength.QuadPart, + callbackInfo->FileSize.QuadPart); + }; + auto vfs = reinterpret_cast(callbackInfo->CallbackContext); Q_ASSERT(vfs->metaObject()->className() == QByteArrayLiteral("OCC::VfsCfApi")); const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath)); @@ -170,6 +181,7 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const return; } + pendingTransferInfo(); qCDebug(lcCfApiWrapper) << "Successfully triggered hydration for" << path << requestId; // Block and wait for vfs to signal back the hydration is ready