artehe / Netimobiledevice

A C#/dotnet implementation for working with iOS devices (iPhone, iPad, iPod).
https://github.com/artehe/Netimobiledevice
MIT License
14 stars 7 forks source link

Change Password followed by Starting a Backup fails #41

Open iwhiffin opened 1 month ago

iwhiffin commented 1 month ago

When a user starts a backup process, I would like to check if the backup will be encrypted and if not, prompt them to add a password.

I have the check and setting password working fine. I have the backup working fine.

But I cannot do both together without restarting the application in between.

Step 1: User selects to create a backup. Step 2: Device is checked to see if encryption is in use. a) If it is, proceed with backup. (This works) b) if it isn't, prompt the user to add a password. i)They can choose to proceed without a password and backup anyway (this works) ii) They can choose to add a password (this works) and start the backup (this is where is fails)

I've tried numerous things, but it seems that the changing/setting of a password ties up the tool as the Backup process just sits there not doing anything.

Restarting the app and starting the backup works fine but is not really feasible.

Any tips?

Thank you.

artehe commented 1 month ago

That sounds odd I'm fairly sure it should just work.

However one thign you can do is just recreate the Servivce so something like

 using (LockdownClient lockdown = MobileDevice.CreateUsingUsbmux(logger: logger)) {
            using (DeviceBackup backupJob = new DeviceBackup(lockdown, path)) {
                 // Check backup encryption / set password etc
            }

           using (DeviceBackup backupJob = new DeviceBackup(lockdown, path)) {
                 // Do backup
            }
        }
iwhiffin commented 3 weeks ago

Thanks for the suggestion.

I'd tried a bunch of stuff to no avail including recreating the service, but your magic must have been all that was required as it is working now... No idea what is different but clearly my mistake.

Thanks again!

Elanchezhiyan-P commented 3 weeks ago

@iwhiffin, Could you please send me the PR (if raised) or code snippet for the below process?

a) If it is, proceed with backup. (This works) b) if it isn't, prompt the user to add a password. i)They can choose to proceed without a password and backup anyway (this works) ii) They can choose to add a password (this works) and start the backup (this is where is fails)