Dr-Emann / applesauce

Transparent compression for Apple File System Compression (AFSC)
GNU General Public License v3.0
21 stars 0 forks source link

Applesauce

Applesauce is a command-line interface (CLI) program written in Rust that compresses, decompresses, and prints information about compressed files for HFS+/APFS transparent compression on macOS. It is based on afsctool and offers several key improvements, including better performance, improved multithreading (even for a single file), and reduced memory usage. Applesauce supports all three compression algorithms used by HFS+/APFS: LZFSE, LZVN, and ZLIB.

Installation

Install via Homebrew

To install Applesauce using Homebrew, run the following command:

brew install Dr-Emann/homebrew-tap/applesauce

Install prebuilt binaries via shell script

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/Dr-Emann/applesauce/releases/latest/download/applesauce-cli-installer.sh | sh

Manual build with Cargo

Details To install Applesauce using Cargo, follow these steps: 1. Install Rust and Cargo using the instructions provided at [rust-lang.org](https://www.rust-lang.org/tools/install). 2. Clone this repository to your local machine. 3. In the project directory, run `cargo build --release` to build the program. 4. The built binary can be found in the `target/release` directory.

Usage

To use Applesauce, run the following command:

applesauce [compress|decompress|info] file/directory

The options are as follows:

For example, to compress a file named example.txt using the ZLIB compression algorithm, you would run:

applesauce compress -c ZLIB example.txt

Features

Applesauce has the following key features:

Compression Algorithms

Applesauce supports three compression algorithms:

Applesauce defaults to using LZFSE compression. Depending on the type of data being compressed and the desired balance between compression ratio and speed, one of these algorithms may be more suitable than the others.

Improvements Over Afsctool

Applesauce is based on afsctool, but offers several key improvements, including:

Improved Performance

afcstool can compress multiple files in parallel, but applesauce parallelizes at the block level, so even a single file can be compressed in parallel. Applesauce can often be several times faster than afsctool, especially for small numbers of large files.

Reduced Memory Usage

afcstool will load the entire file into memory before compressing it (although it does attempt to use mmap for large files). Applesauce will only keep the block(s) currently being compressed in memory.

Better User Interface

Applesauce outputs a pretty progress bar while it's working, providing a more user-friendly experience than afsctool's sparse output.

Better Compression With Many Small Files

afsctool will compress a file which fits in the xattr after compression, even if doing so actually adds more overhead than leaving the file uncompressed. Applesauce will not compress a file if it would result in a larger file.

Better Error Handling

afcstool overwrites files in place. Although it attempts to restore the file if an error occurs, if it is forcefully terminated while compressing a file, the file may be left in an invalid state.

Applesauce compresses/decompresses files to a temporary file and then atomically renames the temporary file to the original file only when the operation is complete: the file is never left in an invalid state, even if the program is harshly terminated.

This is no replacement for backups: please do not use applesauce on files you cannot afford to lose.

License

Applesauce is licensed under the GNU General Public License version 3 (GPLv3).

Contributions

Contributions to Applesauce are welcome! If you would like to contribute code, please open a pull request on the GitHub repository. If you find a bug or have a feature request, please open an issue on the repository.