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/hydratation errors handling #6165

Closed
wants to merge 4 commits into from
Closed
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
36 changes: 24 additions & 12 deletions src/libsync/vfs/cfapi/cfapiwrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/vfs/cfapi/cfapiwrapper.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/vfs/cfapi/cfapiwrapper.cpp

File src/libsync/vfs/cfapi/cfapiwrapper.cpp (lines 234, 235, 261, 262): Code does not conform to Custom style guidelines.
* Copyright (C) by Kevin Ottens <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -50,6 +50,7 @@

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 };
Expand All @@ -71,6 +72,7 @@

const auto isDownloadFinished = ((offset + currentBlockLength) == totalLength);
if (isDownloadFinished) {
qCInfo(lcCfApiWrapper) << "download is finished";
return;
}

Expand All @@ -90,7 +92,7 @@

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,
Expand Down Expand Up @@ -143,6 +145,7 @@
qCInfo(lcCfApiWrapper) << "VFS replied for hydration of" << path << requestId << "status was:" << hydrationRequestResult;

if (!hydrationRequestResult) {
qCInfo(lcCfApiWrapper) << "calling sendTransferError";
sendTransferError();
return;
}
Expand Down Expand Up @@ -190,6 +193,7 @@
protrudingData = data.right(protudingSize);
data.chop(protudingSize);

qCInfo(lcCfApiWrapper) << "calling sendTransferInfo" << dataOffset;
sendTransferInfo(data, dataOffset);
dataOffset += data.size();
};
Expand All @@ -212,7 +216,7 @@
});

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();
}
Expand All @@ -221,19 +225,24 @@
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<OCC::HydrationJob::Status>(hydrationJobResult) != OCC::HydrationJob::Success) {
if (hydrationJobResult != OCC::HydrationJob::Success) {
qCInfo(lcCfApiWrapper) << "calling sendTransferError";
sendTransferError();
}
}
Expand All @@ -243,16 +252,19 @@
{
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<OCC::VfsCfApi *>(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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libsync/vfs/cfapi/vfs_cfapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/vfs/cfapi/vfs_cfapi.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/vfs/cfapi/vfs_cfapi.h

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/vfs/cfapi/vfs_cfapi.h

File src/libsync/vfs/cfapi/vfs_cfapi.h (lines 19): Code does not conform to Custom style guidelines.
* Copyright (C) by Kevin Ottens <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -16,11 +16,11 @@
#include <QObject>
#include <QScopedPointer>

#include "hydrationjob.h"
#include "common/vfs.h"
#include "common/plugin.h"

namespace OCC {
class HydrationJob;
class VfsCfApiPrivate;
class SyncJournalFileRecord;

Expand Down Expand Up @@ -57,7 +57,7 @@

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);
Expand Down
Loading