[gnome-keysign: 10/16] discover: fix error if discover was stopped



commit 7ba232142fdc1cf5f04711817c6768796a199250
Author: RyuzakiKK <aasonykk gmail com>
Date:   Wed Dec 5 18:00:24 2018 +0100

    discover: fix error if discover was stopped
    
    If a user typed really fast in the receive tab, self.stopped was set at
    True and the return of the "start()" function contained an empty
    message.
    Then in receive.py with "_receive()" the message was propagated reaching
    the user interface as if an error occurred.
    
    With this fix we return the LonelyError that is already gracefully
    handled in "_receive()".
    LonelyError fits this scenario because it indicates a connection stopped
    before a transfer.

 keysign/discover.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/keysign/discover.py b/keysign/discover.py
index 6565411..f621970 100644
--- a/keysign/discover.py
+++ b/keysign/discover.py
@@ -88,7 +88,9 @@ class Discover:
         if self.stopped:
             key_data = None
             success = False
-            message = ""
+            # We use the LonelyError in a similar way as Wormhole does.
+            # That is to indicate that the connection as been stopped before a transfer.
+            message = LonelyError
 
         log.debug("Returning key: %r, success: %r, message: %r",
                   key_data, success, message)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]