Improved logic that removes top-level folder from archives when needed

Whether we remove the top-level folder from the archive depends now on the zip itself and not on where it was downloaded from. That makes it work installing local files too.

Closes #3582