Skip to content

Throw exception instead of silently failing if zip save/close fails #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2020

Conversation

BretJohnson
Copy link

I saw a case before on my machine where closing the zip would fail to write out changes, but it would fail silently, so it wasn't obvious there was a problem there.

See more details here: https://xamarinhq.slack.com/archives/C03CEGRUW/p1588784048377800

This PR makes those errors explicit, throwing an exception on Close failures, so that the user will see there's a problem, that the ZIP/APK didn't actually get updated.

I'm honestly a little nervous about this change - it seems good conceptually but might there be cases in practice where it's better to fail silently?
I'm not sure, but I wanted to create a PR to get feedback from you all on that.

As for my machine, it was a failure to create temp file error (see Slack). The problem went away after I rebooted and I wasn't able to reproduce it again. Probably it was some file in use issue of some kind. This may or may not be a problem customers see in practice (of course, since it fails silently, we have less visibility into whether it is a problem in practice - making the error explicit would help with that at least).

I saw a case before on my machine where closing the zip would fail to write out changes, but it would fail silently, so it wasn't obvious there was a problem there.

See more details here: https://xamarinhq.slack.com/archives/C03CEGRUW/p1588784048377800

This PR makes those errors explicit, throwing an exception on Close failures, so that the user will see there's a problem, that the ZIP/APK didn't actually get updated.

I'm honestly a little nervous about this change - it seems good conceptually but might there be cases in practice where it's better to fail silently?
I'm not sure, but I wanted to create a PR to get feedback from you all on that.

As for my machine, it was a failure to create temp file error (see Slack). The problem went away after I rebooted and I wasn't able to reproduce it again. Probably it was some file in use issue of some kind. This may or may not be a problem customers see in practice (of course, since it fails silently, we have less visibility into whether it is a problem in practice - making the error explicit would help with that at least).
@BretJohnson
Copy link
Author

Running out of disk space is another example of a save problem that could happen in practice, though it's probably fairly rare, for APKs.

ZipArchive.cs Outdated
if (Native.zip_close (archive) < 0)
throw GetErrorException ();
}
finally {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could just put finally hanging behind the brace on the line above then LGTM :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@grendello
Copy link
Contributor

@BretJohnson This is breaking behavior change, indeed, but a good one. I don't know why we didn't do it in the first place, probably a simple omission. Libraries should not hide problems - they should let the app handle the issues (if the library can't deal with them itself, of course).

@grendello grendello merged commit dd5e939 into master May 15, 2020
@dellis1972 dellis1972 deleted the report-failures-to-save branch February 2, 2021 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants