wh0 / nix-cache-view

in-browser .nar explorer
https://wh0.github.io/nix-cache-view/
MIT License
12 stars 1 forks source link

Restructure decompression code to allow for other algorithms #10

Closed wh0 closed 1 year ago

wh0 commented 1 year ago

Currently we go through like this:

  1. Refer to this thing we download as the .xz file
  2. Check that the compression algorithm is actually "xz"
  3. If not, raise an error
  4. Decompress with xz

See the code: https://github.com/wh0/nix-cache-view/blob/1a5bba2d55272506ff2f7c6af27cf0bf92d79474/misc.js#L198

Change it to be more like:

  1. Refer to this thing we download as the compressed file
  2. Look at the compression algorithm
  3. If it's "xz," decompress with xz
  4. Otherwise, raise an error

At this time let's not actually add any other algorithms. But we should make it simple for when we do. Or maybe we could trivially support none?

wh0 commented 1 year ago

680ce9ac32c5c19c3266874191bde963045a79c3