Opening an archive like a folder: two ways

Double-click and browse: the same experience built two different ways, one that needs a filesystem extension and one that works in a sandbox.

By · · Part of Files, Unwrapped: building a Mac archive app

One gesture, two machines

You choose browsing for double-click, then double-click photos.zip. A Finder window shows what's inside. You press Back and you're in Downloads again. That is the whole contract, and I want it to hold no matter how you got Peel.

But I ship Peel in two editions, and they live under different rules. The direct download isn't sandboxed and can carry a filesystem extension. The Mac App Store edition is sandboxed and can't. The last piece was about the first kind. This one is about how the second reaches the same place by a different road, and what I'd steal from that road even if I never had to take it. Which of those a double-click does is your choice (browse, extract or ask), and it defaults to ask.

Way one: a real volume

In the direct edition, when browsing is the choice, the first thing Peel tries is to mount the archive as a read-only volume with its FSKit module (PeelFS). Finder lists directories from an index of the archive, and a ZIP entry is produced when something reads it. A solid 7z or RAR, or a compressed tar, is unpacked once into a bounded cache on the first read, because reading its entries one at a time would decompress from the start each time. Encrypted archives aren't mounted. It is the closest thing to the archive actually being a folder.

The cost of that purity is dependence. The module has to be loaded by macOS, the user has to have the File System Extensions switch on, and on macOS 27.0.1, where I'm testing, that switch doesn't save for third-party modules (Apple feedback FB25209882). So until that is fixed, even the direct edition falls back to the second way. The FSKit path is tried first so it takes over by itself the day the system allows it.

Way two: a view you can reuse

The fallback is what I call a browse volume, and it is simpler than it sounds. Peel runs its engine to extract the archive into a folder beside the archive, hides a small metadata file inside it, and points Finder at the result. It is a real folder of real files, so every app and every Finder feature works with it, including Quick Look and drag-out.

That sounds like exactly the Archive Utility behavior I was trying to avoid, and it would be, if the design stopped there. Three decisions keep it from feeling like an unzip tool.

It is a cache, not a product. Nobody asked for an extracted copy. The folder exists so that browsing works, and Peel treats it like a cache: by default it expires after 24 hours without being opened, and the total is capped at 2 GB. Settings has a Clear Cache button.

It is reused. When you open the same archive again, Peel looks at the folder's metadata. If it names this archive and the stamp still matches, the folder is used as it is: no extraction, no password prompt, no delay. The stamp is the archive's modification time and its size. If either changes, the view is stale and gets rebuilt.

It never destroys your work. If the archive changed and the folder beside it is untouched since Peel made it, it goes to the Trash and the new one is built in its place. If you added to it or edited it, Peel releases it to you, removes its marker and leaves the folder alone, and the new view goes somewhere else. A folder that isn't Peel's is never touched at all, and Peel never clears out a folder beside an archive to build in it. I'd rather leave a stale cache around than delete a file someone cared about.

The sandbox changes where, not what

The App Store edition runs in the macOS sandbox. That has two consequences for browsing.

First, there is no filesystem extension. That edition doesn't include PeelFS, and its build is checked to contain none. There is also no Finder Sync extension, which is why the right-click menu is a direct-edition feature, and the App Store edition leans on Finder's Services menu instead.

Second, a sandboxed app can read the file it was handed but not write into that file's folder. Extracting a browse view beside the archive, the natural place, needs write access it may not have. Peel handles this without asking: it builds the folder beside the archive where it may write there, and otherwise in its own container. Finder's title bar still shows the archive's name either way, because the folder is named after it. For a plain open, nobody gets a permission dialog.

The engine runs as a helper that inherits the app's sandbox, so it has the same file access and no more. Opening the finished folder is also simpler than in the direct edition. Without the scripting permission, Peel can't retarget your existing Finder window, so it asks Finder to open the folder, and you get a new window or tab. That is the one visible difference between the two editions, and it is the cost of not holding an Apple Events grant. (The direct edition does the same if you decline Automation.)

Why both land in the same place

The two mechanisms share almost nothing underneath, yet they converge, because I wrote down the user experience first and treated mechanisms as replaceable.

| | Mounted volume | Browse volume | | --- | --- | --- | | Work up front | Index; ZIP entries on read | Full extraction | | Disk used | A bounded scratch cache | A cache folder, with limits | | Needs from the OS | An extension the user must enable | Nothing special | | Where it works | Direct edition, once the extension is enabled | Both editions | | Honest weakness | Depends on a system switch I don't control | First open of a big archive takes a while |

The mount is better in principle. The browse volume is better in availability, and availability won, because an app that does nothing when the system says no is not an app.

Both routes also share a front door. The open flow is the same for each: receive the file, stay out of the way, look for an existing view, build one if needed, and navigate Finder to the result. Password-protected archives take the same secure prompt in both. Progress shows up on the archive's icon in Finder after half a second, so reopening something cached never flashes a progress bar, and cancelling from Finder stops the work and removes the partial folder.

The idea I'd keep: key the view to the thing's identity

If I were summarizing what this taught me in one sentence, it would be this: don't cache by name, cache by identity.

The tempting design is to say that a folder called project beside project.zip is the view of that zip. That works until someone re-downloads a different project.zip with the same name, and then you are showing them yesterday's contents under today's file. The stamp fixes it cheaply. Modification time and size are not a cryptographic proof, but they are free to read, they change when the file changes, and they never require reading the file itself. A hash would be stronger and slower, and for a tool whose whole point is to be quick to open, I made the pragmatic call.

The same thinking shows up in several places. The metadata records which archive a folder belongs to, so two archives with the same name can't claim each other's folders. Mount points and cache locations include a short hash of the archive's path, so same-named archives in different places don't collide. The decision to delete or keep a folder depends on whether the user has touched it, not on how old it is.

If you build anything that makes a derived copy of a user's file, the discipline is the same. Know what the copy came from. Know whether it still matches. Know whether anyone has touched it since. Only then decide what to do with it.

What was hard, and what I'd warn you about

The hard part wasn't the extraction. The engine already did that. The hard part was ownership. A folder beside someone's archive looks exactly like something they made, and sooner or later they will make it theirs by dropping a file into it. Getting the rules for that right, so that Peel never deletes something a person has edited and never leaves clutter they didn't ask for, took more design than any parsing code did.

I'd also warn you about the temptation to treat the fallback as a stopgap. I wrote the browse volume as the thing to use until the mount worked. It is the path Peel takes in both editions whenever PeelFS isn't mounted, which today is every time, and it deserved the care of a primary feature from the start. If your clean design depends on the system's cooperation, then your real product is whatever you build for when it doesn't cooperate.

There is still a gap I'm honest about. A browse volume is an ordinary writable folder, and until you change it, it is a cache wearing a folder's clothes. I think the ownership rules handle that safely, but it is a trade I'd like to close someday, and the mounted volume is how.

Peel is free for macOS 13 or later. Get Peel, or install it with brew install --cask snackstudio/tap/peel.

Next in the series: A Rust engine behind a SwiftUI app