Skip to content

Commit c3ebfff

Browse files
mmastracclaude
andcommitted
feat: add SCCACHE_FILE_CLONE_COMPRESS for post-write compression
When SCCACHE_FILE_CLONE=true, users can set SCCACHE_FILE_CLONE_COMPRESS to a command that will be spawned on each cache entry directory after writing. The entry directory path is appended to the command. Example: SCCACHE_FILE_CLONE_COMPRESS="applesauce compress -c lzfse" applies APFS transparent compression on macOS, reducing cache disk usage while keeping files transparently readable and reflink-capable. The command runs in the background and failures are silently ignored. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4801769 commit c3ebfff

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

docs/Configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ export SCCACHE_MULTILEVEL_WRITE_POLICY="all"
224224
* `SCCACHE_CACHE_SIZE` maximum size of the local on disk cache i.e. `2G` - default is 10G
225225
* `SCCACHE_DIRECT` enable/disable preprocessor caching (see [the local doc](Local.md))
226226
* `SCCACHE_LOCAL_RW_MODE` the mode that the cache will operate in (`READ_ONLY` or `READ_WRITE`)
227+
* `SCCACHE_FILE_CLONE` enable reflink-based uncompressed disk cache (see [FileClone docs](FileClone.md))
228+
* `SCCACHE_FILE_CLONE_COMPRESS` command to run on each cache entry directory after writing (e.g., `applesauce compress -c lzfse`). The entry directory path is appended to the command. Only used when `SCCACHE_FILE_CLONE=true`.
227229

228230
#### s3 compatible
229231

src/cache/disk.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,26 @@ fn write_uncompressed_entry(cache_root: &Path, key_dir: &Path, entry: CacheWrite
139139
}
140140
}
141141

142+
// If SCCACHE_FILE_CLONE_COMPRESS is set, spawn the command with the entry
143+
// directory appended. This allows users to apply transparent compression
144+
// (e.g., APFS compression via `applesauce compress -c lzfse`).
145+
if let Ok(cmd) = std::env::var("SCCACHE_FILE_CLONE_COMPRESS") {
146+
if let Some(parts) = shlex::split(&cmd) {
147+
if let Some((program, args)) = parts.split_first() {
148+
let mut command = std::process::Command::new(program);
149+
command
150+
.args(args)
151+
.arg(&entry_dir)
152+
.stdout(std::process::Stdio::null())
153+
.stderr(std::process::Stdio::null());
154+
match command.spawn() {
155+
Ok(_) => trace!("Spawned file_clone compress: {} {:?}", cmd, entry_dir),
156+
Err(e) => trace!("Failed to spawn file_clone compress: {}", e),
157+
}
158+
}
159+
}
160+
}
161+
142162
Ok(())
143163
}
144164

0 commit comments

Comments
 (0)