diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index ee729896300a5..fe316b7d3e0d8 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -50,6 +50,7 @@ constexpr auto syncRootManagerRegKey = R"(SOFTWARE\Microsoft\Windows\CurrentVers void cfApiSendTransferInfo(const CF_CONNECTION_KEY &connectionKey, const CF_TRANSFER_KEY &transferKey, NTSTATUS status, void *buffer, qint64 offset, qint64 currentBlockLength, qint64 totalLength) { + qCInfo(lcCfApiWrapper) << status << buffer << offset << currentBlockLength << totalLength; CF_OPERATION_INFO opInfo = { 0 }; CF_OPERATION_PARAMETERS opParams = { 0 }; @@ -71,6 +72,7 @@ void cfApiSendTransferInfo(const CF_CONNECTION_KEY &connectionKey, const CF_TRAN const auto isDownloadFinished = ((offset + currentBlockLength) == totalLength); if (isDownloadFinished) { + qCInfo(lcCfApiWrapper) << "download is finished"; return; } @@ -90,7 +92,7 @@ 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; + qCDebug(lcCfApiWrapper) << "Fetch data callback called. File size:" << callbackInfo->FileSize.QuadPart; const auto sendTransferError = [=] { cfApiSendTransferInfo(callbackInfo->ConnectionKey, callbackInfo->TransferKey, @@ -143,6 +145,7 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const qCInfo(lcCfApiWrapper) << "VFS replied for hydration of" << path << requestId << "status was:" << hydrationRequestResult; if (!hydrationRequestResult) { + qCInfo(lcCfApiWrapper) << "calling sendTransferError"; sendTransferError(); return; } @@ -190,6 +193,7 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const protrudingData = data.right(protudingSize); data.chop(protudingSize); + qCInfo(lcCfApiWrapper) << "calling sendTransferInfo" << dataOffset; sendTransferInfo(data, dataOffset); dataOffset += data.size(); }; @@ -212,7 +216,7 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const }); QObject::connect(vfs, &OCC::VfsCfApi::hydrationRequestFinished, &loop, [&](const QString &id) { - qDebug(lcCfApiWrapper) << "Hydration finished for request" << id; + qCDebug(lcCfApiWrapper) << "Hydration finished for request" << id; if (requestId == id) { loop.quit(); } @@ -221,19 +225,24 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const loop.exec(); if (!hydrationRequestCancelled && !protrudingData.isEmpty()) { - qDebug(lcCfApiWrapper) << "Send remaining protruding data. Size:" << protrudingData.size(); + qCInfo(lcCfApiWrapper) << "Send remaining protruding data. Size:" << protrudingData.size(); + qCInfo(lcCfApiWrapper) << "calling sendTransferInfo" << dataOffset; sendTransferInfo(protrudingData, dataOffset); } - int hydrationJobResult = OCC::HydrationJob::Status::Error; - const auto invokeFinalizeResult = QMetaObject::invokeMethod( - vfs, [=] { vfs->finalizeHydrationJob(requestId); }, Qt::BlockingQueuedConnection, + auto hydrationJobResult = OCC::HydrationJob::Status::Error; + const auto invokeFinalizeResult = QMetaObject::invokeMethod(vfs, + [=] () -> OCC::HydrationJob::Status { + return vfs->finalizeHydrationJob(requestId); + }, + Qt::BlockingQueuedConnection, &hydrationJobResult); if (!invokeFinalizeResult) { - qCritical(lcCfApiWrapper) << "Failed to finalize hydration job for" << path << requestId; + qCCritical(lcCfApiWrapper) << "Failed to finalize hydration job for" << path << requestId; } - if (static_cast(hydrationJobResult) != OCC::HydrationJob::Success) { + if (hydrationJobResult != OCC::HydrationJob::Success) { + qCInfo(lcCfApiWrapper) << "calling sendTransferError"; sendTransferError(); } } @@ -243,16 +252,19 @@ void CALLBACK cfApiCancelFetchData(const CF_CALLBACK_INFO *callbackInfo, const C { const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath)); - qInfo(lcCfApiWrapper) << "Cancel fetch data of" << path; + qCInfo(lcCfApiWrapper) << "Cancel fetch data of" << path; auto vfs = reinterpret_cast(callbackInfo->CallbackContext); Q_ASSERT(vfs->metaObject()->className() == QByteArrayLiteral("OCC::VfsCfApi")); const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); - const auto invokeResult = QMetaObject::invokeMethod( - vfs, [=] { vfs->cancelHydration(requestId, path); }, Qt::QueuedConnection); + const auto invokeResult = QMetaObject::invokeMethod(vfs, + [=] () { + vfs->cancelHydration(requestId, path); + }, + Qt::QueuedConnection); if (!invokeResult) { - qCritical(lcCfApiWrapper) << "Failed to cancel hydration for" << path << requestId; + qCCritical(lcCfApiWrapper) << "Failed to cancel hydration for" << path << requestId; } } diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.cpp b/src/libsync/vfs/cfapi/vfs_cfapi.cpp index d622913fd6d1a..f0e712708810b 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.cpp +++ b/src/libsync/vfs/cfapi/vfs_cfapi.cpp @@ -453,7 +453,7 @@ void VfsCfApi::onHydrationJobFinished(HydrationJob *job) } } -int VfsCfApi::finalizeHydrationJob(const QString &requestId) +HydrationJob::Status VfsCfApi::finalizeHydrationJob(const QString &requestId) { qCDebug(lcCfApi) << "Finalize hydration job" << requestId; // Find matching hydration job for request id diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.h b/src/libsync/vfs/cfapi/vfs_cfapi.h index b675ae389f0e7..0af05fb77ca1e 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.h +++ b/src/libsync/vfs/cfapi/vfs_cfapi.h @@ -16,11 +16,11 @@ #include #include +#include "hydrationjob.h" #include "common/vfs.h" #include "common/plugin.h" namespace OCC { -class HydrationJob; class VfsCfApiPrivate; class SyncJournalFileRecord; @@ -57,7 +57,7 @@ class VfsCfApi : public Vfs void cancelHydration(const QString &requestId, const QString &path); - int finalizeHydrationJob(const QString &requestId); + HydrationJob::Status finalizeHydrationJob(const QString &requestId); public slots: void requestHydration(const QString &requestId, const QString &path);