From e1ece7d5bf4452f80bc7fa7b3da2bf63249dd0f8 Mon Sep 17 00:00:00 2001 From: Felix Weilbach Date: Tue, 23 Mar 2021 10:02:04 +0100 Subject: [PATCH] Check reading from journal was successful before remove placeholder Signed-off-by: Felix Weilbach --- src/libsync/vfs/cfapi/vfs_cfapi.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.cpp b/src/libsync/vfs/cfapi/vfs_cfapi.cpp index 925dacf35b3ab..580c15b992bca 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.cpp +++ b/src/libsync/vfs/cfapi/vfs_cfapi.cpp @@ -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)) { + 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); }