[libdazzle] file-transfer: add error with no transfers



commit aaa2dc30bb7e196f2011f10bb7acd5d222e56b1c
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jan 5 19:46:05 2019 -0800

    file-transfer: add error with no transfers
    
    this helps ensure that incorrect usage from _add() doesn't result in
    successful code paths by consumers.

 src/files/dzl-file-transfer.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/src/files/dzl-file-transfer.c b/src/files/dzl-file-transfer.c
index bd04255..2182e2d 100644
--- a/src/files/dzl-file-transfer.c
+++ b/src/files/dzl-file-transfer.c
@@ -681,10 +681,19 @@ dzl_file_transfer_execute (DzlFileTransfer  *self,
 
   if (priv->executed)
     {
-      g_task_return_new_error (task,
-                               G_IO_ERROR,
-                               G_IO_ERROR_INVAL,
-                               "Transfer can only be executed once.");
+      g_set_error (error,
+                   G_IO_ERROR,
+                   G_IO_ERROR_INVAL,
+                   "Transfer can only be executed once.");
+      DZL_RETURN (FALSE);
+    }
+
+  if (priv->opers->len == 0)
+    {
+      g_set_error (error,
+                   G_IO_ERROR,
+                   G_IO_ERROR_INVAL,
+                   "Transfer can only be executed once.");
       DZL_RETURN (FALSE);
     }
 
@@ -728,6 +737,15 @@ dzl_file_transfer_execute_async (DzlFileTransfer     *self,
 
   priv->executed = TRUE;
 
+  if (priv->opers->len == 0)
+    {
+      g_task_return_new_error (task,
+                               G_IO_ERROR,
+                               G_IO_ERROR_INVAL,
+                               "No transfers were provided to execute");
+      DZL_EXIT;
+    }
+
   g_task_set_check_cancellable (task, TRUE);
   g_task_set_return_on_cancel (task, TRUE);
   g_task_set_priority (task, io_priority);


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