mihaip / infinite-mac

A classic Mac loaded with everything you'd want
https://infinitemac.org
Apache License 2.0
1.16k stars 70 forks source link

Add support for compressed disk images #204

Open mihaip opened 1 year ago

mihaip commented 1 year ago

Ideally without having to recompress the disk image (which would go over CPU use limits of the Cloudflare Worker), but this may not be possible for all compression formats (see https://github.com/vasi/lzopfs#what-compression-formats-are-supported).

A pattern like https://github.com/mattgodbolt/zindex or https://github.com/circulosmeos/gztool where we build an index may be possible.

Requested for https://archive.org/details/macpeople-1998-no-2 and others

mihaip commented 9 months ago

@gingerbeardman I looked into implementing this using the download links that you mentioned in #273, but I was not able to make it work when running on Cloudflare Workers. I tried two different approaches:

  1. Download the entire (decompressed) file and put it into Cloudflare's cache. The docs say that you can then make range requests against the cache, but while that works locally, it doesn't when deployed (I always get back the full body with a 200 status, instead of a partial response with a 206 status)
  2. Download the entire file and then chop it up into 128K chunks that are cached. That runs into limitation of subrequests that can be issued.

I'll look into doing this entirely on the client, it looks like the archive.org server for archive contents has liberal CORS headers.

gingerbeardman commented 9 months ago

Thanks for your efforts so far!

mihaip commented 9 months ago

Looks like that works, albeit very slowly. Here's an example: https://infinitemac.org/1996/KanjiTalk%207.5.3?cdrom=https://archive.org/download/bmac-vol3-1996-03/BMAC-VOL3-1996-03.ISO.7z

gingerbeardman commented 9 months ago

I need better WiFi. I'll check it after the Christmas break

that-ben commented 9 months ago

Looks like that works, albeit very slowly. Here's an example: https://infinitemac.org/1996/KanjiTalk%207.5.3?cdrom=https://archive.org/download/bmac-vol3-1996-03/BMAC-VOL3-1996-03.ISO.7z

Does not work in Firefox under macOS 14:

Screenshot 2023-12-27 at 11 00 22 AM Screenshot 2023-12-27 at 11 03 18 AM
mihaip commented 9 months ago

@that-ben Oops, some leftover code that was affecting Firefox only. Should work now.

that-ben commented 9 months ago

So basically, as it is right now, when you request a .7z file, it downloads the whole file, then decompresses it and attaches it to the emulator, correct? And if so, what would happen if we requested a 7zipped 4.7GB DVD image, would it still work?

Also, is it supposed to work with .zip archives too or is it only for .7z files?

...wanted to close the Japanese yellow bulb info window in the Finder after spending half an hour downloading that ARCHIVE.ORG 7z file in your link only to end up hitting CMD-W and closing the whole InfiniteMac browser tab. Well that sucks. Again.

mihaip commented 9 months ago

That sounds about right. Any size image should work, but it'll take longer to download (depending on your internet connection and archive.org's state) and in Firefox it'll end up being held in-memory, which may not work for a DVD image.

It also works with .zip (if there are other archive types that archive.org displays the contents of, I can add those too).

that-ben commented 9 months ago

Try .sit ... JK 🤣