From 1d4ac48da49809e3c38574b711697cbb2ee0d773 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 21 Jun 2019 21:31:21 +0200 Subject: idevicebackup2: Handle errors when receiving files and report back to device --- tools/idevicebackup2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 1e6ddf7..0aae36e 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -1004,6 +1004,8 @@ static int mb2_handle_receive_files(mobilebackup2_client_t mobilebackup2, plist_ plist_t node = NULL; FILE *f = NULL; unsigned int file_count = 0; + int errcode = 0; + char *errdesc = NULL; if (!message || (plist_get_node_type(message) != PLIST_ARRAY) || plist_array_get_size(message) < 4 || !backup_dir) return 0; @@ -1105,7 +1107,10 @@ static int mb2_handle_receive_files(mobilebackup2_client_t mobilebackup2, plist_ fclose(f); file_count++; } else { - printf("Error opening '%s' for writing: %s\n", bname, strerror(errno)); + errcode = errno_to_device_error(errno); + errdesc = strerror(errno); + printf("Error opening '%s' for writing: %s\n", bname, errdesc); + break; } if (nlen == 0) { break; @@ -1144,9 +1149,8 @@ static int mb2_handle_receive_files(mobilebackup2_client_t mobilebackup2, plist_ if (dname != NULL) free(dname); - // TODO error handling?! plist_t empty_plist = plist_new_dict(); - mobilebackup2_send_status_response(mobilebackup2, 0, NULL, empty_plist); + mobilebackup2_send_status_response(mobilebackup2, errcode, errdesc, empty_plist); plist_free(empty_plist); return file_count; -- cgit v1.1-32-gdbae