artehe/Netimobiledevice

Disconnecting device Info.plist creation while backing up does not report an error (it spins, waiting, instead)

Closed this issue · 4 comments

If you disconnect a device immediately after getting the "Creating Info.plist" notification, but before it fires the BackupJobFileReceiving event for Info.plist, the application spins, waiting for something to complete, and does not recognize the disconnection, or throw an exception, or anything.

To Reproduce
Steps to reproduce the behavior:

  1. Start a wired backup
  2. Disconnect the device immediately after getting the "Creating Info.plist" message but before BackupJobFileReceiving is invoked
  3. Observe that nothing happens. The app will just keep waiting.

Expected behavior
A disconnection notice, of one kind or another (probably via BackupJobError)

Desktop (please complete the following information):

  • OS: Windows & iOS

Smartphone (please complete the following information):

  • Device: reproduced on different devices
  • OS: reproduced on devices both pre and post ios17

Additional context
If you pull the plug right after receiving the BackupJobFileReceiving event, it does throw an exception ("Cannot access a closed file").
If you pull the plug right after "Initializing backup..." it spins forever in ServiceConnection.ReceiveAsync (but that's a separate issue from this one)

Created a PR which I think should hopefully throw DeviceDisconnectedException when the device is disconnected, try it and see what you think

Didn't seem to catch it. It still hangs in that moment in time between the OnStatus() call and the OnFileReceiving() call inside of SaveInfoPropertyList

I think I found the problem. It wasn't checking for 0 bytes read when the connection was broken, and would just spin in Receive and ReceiveAsync waiting for more data.

Perfect thank you! Haven't fully tested it but it looks like somethign I should have done in the first place.

I've merged both your PR and mine and created a new release so please let me know if this is still not working and I'll look into it some more next week.