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

Backup blocks right after creating Info.plist on v0.9.7 #10

Open MarkFassett opened 7 months ago

MarkFassett commented 7 months ago

We pulled version 0.9.7 into our project (we were using 0.7.3, prior to this), and running a backup gets stuck right after it creates the info.plist. It looks like it's trying to send something to the device, and it just never returns. We didn't change anything with our code between the two versions. Is there a change that I need to do that I missed?

artehe commented 7 months ago

I don't think there was that big a difference between those two versions, at least nothing that jumps out in my mind.

The first thought I had was were you trying to backup to a folder which already contained a backup of that device? As if I'm remembering correctly then there would be some things you'd send or try to straight after creating the Info.plist so the device would do an incremental backup rather than a full backup. This would be in response to the DLMessageDownloadFiles message and before the device asks how much free disk space you have.

If that is the case then it's quite possible there is bug there as it's not really something I use much and haven't tested it very well at all.

MarkFassett commented 7 months ago

It's not doing an incremental backup. The contents of the backup folder get wiped completely.

I know one thing you've added is the escrow bag functionality (which is why I was trying to use the updated version). And when I went looking, the file transfer code seemed to be changed a bit (with timeouts and async handling).

MarkFassett commented 7 months ago

I started testing the different versions. It stopped working between 0.80 and 0.90.

MarkFassett commented 7 months ago

So - a bit of a mea culpa - the contents of the folder weren't being wiped completely. When I wiped the folder, it did complete.

So, if I don't wipe the folder, it does seem to never complete (and I'm not getting any messages back). So there may be an issue there, but we also do some funky stuff to the folder (we're only looking for particular files, so we remove things that don't match what we're looking for), and that may cause issues. So maybe there's a bug, maybe not, but at least, I know how to work around it, now, I think...

artehe commented 7 months ago

Cool, glad you've been able to work it out.

Although I'm 100% sure there is a bug of some kind, it should be able to handle the state where the folder isn't empty.

If I recall correctly after the Info.plist is created the iOS device sends a message DLMessageDownloadFiles asking for you to send specific files in the target backup directory (I imagine so it can establish if you are doing a full backup or incremental). I think this part doesn't work properly as it seems to always get stuck, I remember it doing that kind of thing to me but I never really paid much attention to it as I cared more about doing full backups everytime.

So it probably needs looking at for a couple of things:

  1. Fix it so that it does send the requested files properly.
  2. Also handle it in the event like you're where the backup directory is in a bit of a weird state, even if that is just throwing an exception of some kind.