From 282a5e624766402e301ac7b25964b42dc9a64692 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Fri, 29 Oct 2021 15:02:53 -0400
Subject: [PATCH] datatransfer: do not emit failures for outgoing files

In a swarm, if something is wrong, the peer will retry the connection
but for the sender, they have the file so they should be able to see
it and should not see any "Cancelled" error here.
However, in the future, we will need to update the API to provide
status per users and what peers received the file.

Change-Id: Id02ea3f6552557bdc01d3f13504b5b81efb443e9
---
 src/data_transfer.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/data_transfer.cpp b/src/data_transfer.cpp
index 49773e45a7..f7b2a44652 100644
--- a/src/data_transfer.cpp
+++ b/src/data_transfer.cpp
@@ -778,6 +778,12 @@ OutgoingFile::process()
     } catch (...) {
     }
     if (!isUserCancelled_) {
+        // NOTE: emit(code) MUST be changed to improve handling of multiple destinations
+        // But for now, we can just avoid to emit errors to the client, because for outgoing
+        // transfer in a swarm, for outgoingFiles, we know that the file is ok. And the peer
+        // will retry the transfer if they need, so we don't need to show errors.
+        if (interactionId_.empty() && !correct)
+            return;
         auto code = correct ? DRing::DataTransferEventCode::finished
                             : DRing::DataTransferEventCode::closed_by_peer;
         emit(code);
-- 
GitLab