[Spice-devel] [PATCH spice-gtk v2] main: Handle lack of free space for file transfer

Jakub Janků janku.jakub.jj at gmail.com
Tue May 9 16:56:42 UTC 2017


Agent can send FileXferStatusMessage with result
VD_AGENT_FILE_XFER_STATUS_NOT_ENOUGH_SPACE together with info about
amount of available free space when the file to transfer is too large
and the client announces support of this result by sending
VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS
---
 src/channel-main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/channel-main.c b/src/channel-main.c
index bbc5905..b7ed26b 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1321,6 +1321,7 @@ static void agent_announce_caps(SpiceMainChannel *channel)
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND);
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_CLIPBOARD_SELECTION);
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MONITORS_CONFIG_POSITION);
+    VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS);
 
     agent_msg_queue(channel, VD_AGENT_ANNOUNCE_CAPABILITIES, size, caps);
     g_free(caps);
@@ -1870,6 +1871,15 @@ static void main_agent_handle_xfer_status(SpiceMainChannel *channel,
         error = g_error_new_literal(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
                                     _("The spice agent reported an error during the file transfer"));
         break;
+    case VD_AGENT_FILE_XFER_STATUS_NOT_ENOUGH_SPACE: {
+        uint64_t *free_space = (uint64_t *)(msg->data);
+        error = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
+                            "File transfer failed due to lack of free space on remote machine "
+                            "(%s free, %s to transfer)",
+                            g_format_size(*free_space),
+                            g_format_size(spice_file_transfer_task_get_total_bytes(xfer_task)));
+        break;
+    }
     case VD_AGENT_FILE_XFER_STATUS_SUCCESS:
         break;
     default:
-- 
2.9.3



More information about the Spice-devel mailing list