Safety and recovery
A file is never changed until a clone of it exists, and never kept until the result is proven correct.
The steps for one file
- Read the facts. Coldpack opens the file without following links and checks that it is still the same file it chose.
- Sample. In dry run the work stops here and returns an estimate.
- Clone. It makes an APFS clone of the file in a private journal folder, which costs no space, and saves a journal entry. If the volume cannot clone, Coldpack skips the file and touches nothing.
- Write. It stores the compressed data next to the original data, and computes a SHA-256 checksum of the bytes it read.
- Flush. It forces the data to stable storage before the last gate.
- Gate. The original data must still equal the clone, byte for byte, the checksum must match, and the file must not have changed. This is the last action before the point of no return.
- Truncate and flag. Only now Coldpack releases the plain data and marks the file as compressed. It restores the four dates.
- Verify. On a fresh descriptor it reads the file back through the kernel decompressor and compares the checksum. The file must still be the same inode, still compressed and the same size.
- Finish. If everything matches, the clone and the journal entry are deleted. If anything differs, Coldpack restores the file from the clone and then proves the restore.
The rules Coldpack never breaks
- No file is changed without a clone and a journal entry on the same volume first.
- The destructive step happens only after the data equals the clone and the file is stable.
- A file is compressed only if it is eligible, not open, not a clone, and has no other links.
- Every compression is verified byte for byte, through the kernel. Any difference rolls it back.
- A write by you during the operation wins. Coldpack undoes its own change and keeps your newest data.
- Four dates survive every operation (see File dates and Git).
- Recovery runs before new work at every start.
- Some places are never touched.
Never touched
Built-in excludes always apply. No setting and no rule can remove them.
- System folders:
/System,/usr/bin,/usr/lib,/usr/libexec,/usr/sbin,/usr/share,/usr/standalone,/bin,/sbin,/private,/Library/Apple. - Index and event data:
/.Spotlight-V100,/.fseventsd. - Time Machine data, by name anywhere, and whole backup volumes under
/Volumes. ~/Library/Caches,~/Library/Application Support/MobileSync,~/.Trash, and Coldpack's own data folder.
Cloud folders: excluded by default
Editable default rules skip ~/Library/Mobile Documents (iCloud), ~/Library/CloudStorage, and the legacy /Volumes/GoogleDrive location. Remove a rule or put a compress rule first to opt in; all per-file safety checks still apply. Add skip rules for custom synchronized folders. Compatibility with cloud synchronization has not been measured.
Per-file safety checks
Beyond folders, Coldpack skips these kinds of files in every case:
- files that are open in any process;
- hard-linked files;
- files that share all their blocks with a clone;
- files that are not yours, or not writable;
- programs. Compression changes a file's change time, and macOS then refuses to start a new instance of a signed program. Coldpack therefore never touches a file that starts with a Mach-O header, and by default it also skips application bundles and files with an executable bit.
Clones that share blocks
A file that is a full clone of another file is left alone. A file that shares only part of its blocks is safe to compress: disk use cannot grow, because Coldpack never rewrites the shared data. Its saving counts only the bytes that belong to that file alone.
Crash recovery
At every start, before any new work, Coldpack reads the journal. For each entry it decides from the state of the file:
| State at the crash | What recovery does |
|---|---|
| Before the clone was complete | The file was never touched. Leftover temp files are removed. |
| Payload written, plain data still there | Removes Coldpack's own data. If you wrote meanwhile, your data and dates stay. |
| After the point of no return | Restores from the clone, or finishes a compression that was complete. |
| A restore was interrupted | Restores again until the file equals the clone. |
Recovery discards an entry only when it can prove that nothing of the original is left. If it cannot tell (for example a permission error), the entry and the clone stay, the problem is logged, and the next start tries again.
Only one process at a time may change files for a journal folder. The app and every command that changes files take an exclusive lock, and a second process stops at once with a clear message. Read-only commands never run recovery.
If a rollback fails
If Coldpack cannot roll a file back, it stops compressing, runs recovery at once, and shows the failure in the popover. It resumes only when the journal is clean. The rest of the batch goes back to the waiting list, so no file is lost.
Known limits
- A disk cache that loses data on power failure cannot be simulated. The crash tests stop the process at every step, and the design relies on the documented ordering guarantees of APFS.
- Savings can stay invisible while Time Machine local snapshots hold the old blocks.
- A destination mounted outside
/Volumes, or a Time Machine volume with no backup yet, is not recognized as a backup by name.