Check reading from journal was successful before remove placeholder
authorFelix Weilbach <felix.weilbach@nextcloud.com>
Tue, 23 Mar 2021 09:02:04 +0000 (10:02 +0100)
committerFelix Weilbach (Rebase PR Action) <felix.weilbach@t-online.de>
Wed, 24 Mar 2021 10:51:50 +0000 (10:51 +0000)
Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
src/libsync/vfs/cfapi/vfs_cfapi.cpp

index 925dacf35b3abb3aaef94a9f7c7e1d1df299cfb3..580c15b992bca54bfef5e3fca62806e662b4a885 100644 (file)
@@ -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);
 }