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

Check reading from journal was successful before remove placeholder #3028

Merged
merged 1 commit into from
Mar 24, 2021
Merged
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
9 changes: 6 additions & 3 deletions src/libsync/vfs/cfapi/vfs_cfapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,16 +363,19 @@ void VfsCfApi::onHydrationJobFinished(HydrationJob *job)

void VfsCfApi::onHydrationJobCanceled(HydrationJob *job)
{
const auto folderPath = job->localPath();
const auto folderRelativePath = job->folderPath();
SyncJournalFileRecord record;
if (!params().journal->getFileRecord(folderRelativePath, &record)) {
Copy link
Member

Choose a reason for hiding this comment

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

In fact you want to check that and the isValid flag on the record:

SyncJournalFileRecord record;
const auto ok = params().journal->getFileRecord(folderRelativePath, &record);
if (!ok || !record.isValid()) {

qCWarning(lcCfApi) << "Could not read file record from journal for canceled hydration request.";
return;
}

// Remove placeholder file because there might be already pumped
// some data into it
const auto folderPath = job->localPath();
QFile::remove(folderPath + folderRelativePath);

// Create a new placeholder file
SyncJournalFileRecord record;
params().journal->getFileRecord(folderRelativePath, &record);
const auto item = SyncFileItem::fromSyncJournalFileRecord(record);
createPlaceholder(*item);
}
Expand Down