go-update
go-update copied to clipboard
Support updating from an archive
go-update is currently targeted at only updating a single file. And while it's possible to call it repeatedly to update many files, it makes more sense for an archive of many files that compromise an update to be checksummed and verified all at once. Come up with an API or easy example on how to accomplish this. cc: @lukechampine
This would be cleaner if Go had a standard compression interface, like a compress.Deflater(io.Reader) io.Reader. Then you could just pass in a compress.Deflater to the update and it would handle the decompression behind the scenes.
As it stands, I don't see an easy way to do the decompression automatically. You'd need to return the archive to the user and have them decompress it. You also need a way to track the contents of the archive, probably by unpacking it into a specially named hidden folder.
Honestly, I think it would be a huge headache to make compression+archives pluggable. Instead, I would manually support zip and tar.gz. If the user wants to do otherwise, it's still possible to build out of the update primitives.
With that out of the way, the API extensions should be fairly straightforward: just add a FromZip option or equivalent. You don't even need to change the checksum/signature semantics, because they'll still be called on the supplied stream.
It seems like these are two orthogonal problems. One is compression and the other is unarchiving. Since wrapping a decompressor like gzip.NewReader or flate.NewReader is pretty easy in Go (and because it can often be taken care of for you via Content-Encoding over HTTP, I'm okay leaving that to the application to solve.
Solving the unarchiving problem is much harder, I think. When dealing with multi-file updates, you need to actually start thinking about how to add new files, how to delete files that shouldn't . Is the archive all new files, or all patches to existing files? Or a mixture? Is signing done on each file, or the whole archive? etc.
I'm inclined to leave this problem for last since it's going to require the most changes from both an API and implementation standpoint. It may even be worth it to just scope it out and say 'go-update is only about updating single files'.
did this get put into main code ?
I need it :)
sorry, there's been no work been done on this yet