From 86c20b4e3a9e3bf9341c9ca0a8b69ddecd39b00d Mon Sep 17 00:00:00 2001 From: DoronZ Date: Wed, 23 Oct 2024 13:37:16 +0300 Subject: [PATCH] mobilebackup2: fix handling no applications in `Info.plist` --- pymobiledevice3/services/mobilebackup2.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pymobiledevice3/services/mobilebackup2.py b/pymobiledevice3/services/mobilebackup2.py index 8f6315c4..48153a83 100755 --- a/pymobiledevice3/services/mobilebackup2.py +++ b/pymobiledevice3/services/mobilebackup2.py @@ -144,9 +144,10 @@ def restore(self, backup_directory='.', system: bool = False, reboot: bool = Tru # Write /iTunesRestore/RestoreApplications.plist so that the device will start # restoring applications once the rest of the restore process is finished info_plist_path = backup_directory / source / 'Info.plist' - applications = plistlib.loads(info_plist_path.read_bytes())['Applications'] - afc.makedirs('/iTunesRestore') - afc.set_file_contents('/iTunesRestore/RestoreApplications.plist', plistlib.dumps(applications)) + applications = plistlib.loads(info_plist_path.read_bytes()).get('Applications') + if applications is not None: + afc.makedirs('/iTunesRestore') + afc.set_file_contents('/iTunesRestore/RestoreApplications.plist', plistlib.dumps(applications)) dl.dl_loop(progress_callback)