diff options
Diffstat (limited to 'tools/idevicebackup.c')
-rw-r--r-- | tools/idevicebackup.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index 58301f5..04e633e 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c @@ -269,6 +269,30 @@ static void mobilebackup_write_status(const char *path, int status) g_free(file_path); } +static int mobilebackup_read_status(const char *path) +{ + int ret = -1; + plist_t status_plist = NULL; + gchar *file_path = mobilebackup_build_path(path, "Status", ".plist"); + + plist_read_from_filename(&status_plist, file_path); + g_free(file_path); + if (!status_plist) { + printf("Could not read Status.plist!\n"); + return ret; + } + plist_t node = plist_dict_get_item(status_plist, "Backup Success"); + if (node && (plist_get_node_type(node) == PLIST_BOOLEAN)) { + uint8_t bval = 0; + plist_get_bool_val(node, &bval); + ret = bval; + } else { + printf("%s: ERROR could not get Backup Success key from Status.plist!\n", __func__); + } + plist_free(status_plist); + return ret; +} + static int mobilebackup_info_is_current_device(plist_t info) { plist_t value_node = NULL; @@ -874,6 +898,10 @@ int main(int argc, char *argv[]) case CMD_RESTORE: /* TODO: verify battery on AC enough battery remaining */ /* verify if Status.plist says we read from an successful backup */ + if (mobilebackup_read_status(backup_directory) <= 0) { + printf("ERROR: Cannot ensure we restore from a successful backup. Aborting.\n"); + break; + } /* now make sure backup integrity is ok! verify all files */ /* loop over Files entries in Manifest data plist */ /* make sure both .mddata/.mdinfo files are available for each entry */ |