diff options
| author | 2019-06-21 21:31:21 +0200 | |
|---|---|---|
| committer | 2019-06-21 21:31:21 +0200 | |
| commit | 1d4ac48da49809e3c38574b711697cbb2ee0d773 (patch) | |
| tree | 36888eb03c56731c036c2ab79dc519a811cbb870 | |
| parent | aa014c43a7dccd519c0c89605711906b30b98888 (diff) | |
| download | libimobiledevice-1d4ac48da49809e3c38574b711697cbb2ee0d773.tar.gz libimobiledevice-1d4ac48da49809e3c38574b711697cbb2ee0d773.tar.bz2 | |
idevicebackup2: Handle errors when receiving files and report back to device
| -rw-r--r-- | tools/idevicebackup2.c | 10 |
1 files 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_ | |||
| 1004 | plist_t node = NULL; | 1004 | plist_t node = NULL; |
| 1005 | FILE *f = NULL; | 1005 | FILE *f = NULL; |
| 1006 | unsigned int file_count = 0; | 1006 | unsigned int file_count = 0; |
| 1007 | int errcode = 0; | ||
| 1008 | char *errdesc = NULL; | ||
| 1007 | 1009 | ||
| 1008 | if (!message || (plist_get_node_type(message) != PLIST_ARRAY) || plist_array_get_size(message) < 4 || !backup_dir) return 0; | 1010 | if (!message || (plist_get_node_type(message) != PLIST_ARRAY) || plist_array_get_size(message) < 4 || !backup_dir) return 0; |
| 1009 | 1011 | ||
| @@ -1105,7 +1107,10 @@ static int mb2_handle_receive_files(mobilebackup2_client_t mobilebackup2, plist_ | |||
| 1105 | fclose(f); | 1107 | fclose(f); |
| 1106 | file_count++; | 1108 | file_count++; |
| 1107 | } else { | 1109 | } else { |
| 1108 | printf("Error opening '%s' for writing: %s\n", bname, strerror(errno)); | 1110 | errcode = errno_to_device_error(errno); |
| 1111 | errdesc = strerror(errno); | ||
| 1112 | printf("Error opening '%s' for writing: %s\n", bname, errdesc); | ||
| 1113 | break; | ||
| 1109 | } | 1114 | } |
| 1110 | if (nlen == 0) { | 1115 | if (nlen == 0) { |
| 1111 | break; | 1116 | break; |
| @@ -1144,9 +1149,8 @@ static int mb2_handle_receive_files(mobilebackup2_client_t mobilebackup2, plist_ | |||
| 1144 | if (dname != NULL) | 1149 | if (dname != NULL) |
| 1145 | free(dname); | 1150 | free(dname); |
| 1146 | 1151 | ||
| 1147 | // TODO error handling?! | ||
| 1148 | plist_t empty_plist = plist_new_dict(); | 1152 | plist_t empty_plist = plist_new_dict(); |
| 1149 | mobilebackup2_send_status_response(mobilebackup2, 0, NULL, empty_plist); | 1153 | mobilebackup2_send_status_response(mobilebackup2, errcode, errdesc, empty_plist); |
| 1150 | plist_free(empty_plist); | 1154 | plist_free(empty_plist); |
| 1151 | 1155 | ||
| 1152 | return file_count; | 1156 | return file_count; |
