ensure we do properly failed hydration jobs
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Sun, 3 Apr 2022 14:12:42 +0000 (16:12 +0200)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Sun, 3 Apr 2022 14:12:42 +0000 (16:12 +0200)
report status when the job is in error at end of hydration request
instead of doing the opposite

properly set status in db when a file failed to hydrate (still a virtual
file not a real one)

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/vfs/cfapi/cfapiwrapper.cpp
src/libsync/vfs/cfapi/hydrationjob.cpp

index 8fa3aeb9a39d74825f420e3e867bf14349517264..089a8496468e555ffdef71bdabd337a78f28f012 100644 (file)
@@ -229,7 +229,7 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const
         qCritical(lcCfApiWrapper) << "Failed to finalize hydration job for" << path << requestId;
     }
 
-    if (static_cast<OCC::HydrationJob::Status>(hydrationJobResult) == OCC::HydrationJob::Success) {
+    if (static_cast<OCC::HydrationJob::Status>(hydrationJobResult) != OCC::HydrationJob::Success) {
         sendTransferError();
     }
 }
index 12570ebe92f297046bc79a00dae92eceb8a0a2da..2c93ec2df96c76eaed68f2424f740bdc7123e263 100644 (file)
@@ -300,7 +300,16 @@ void OCC::HydrationJob::finalize(OCC::VfsCfApi *vfs)
         return;
     }
 
-    record._type = ItemTypeFile;
+    switch(_status) {
+    case Success:
+        record._type = ItemTypeFile;
+        break;
+    case Error:
+    case Cancelled:
+        record._type = CSyncEnums::ItemTypeVirtualFile;
+        break;
+    };
+
     // store the actual size of a file that has been decrypted as we will need its actual size when dehydrating it if requested
     record._fileSize = FileSystem::getSize(localPath() + folderPath());