Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ export SCCACHE_MULTILEVEL_WRITE_ERROR_POLICY="all"
* `SCCACHE_CACHE_SIZE` maximum size of the local on disk cache i.e. `2G` - default is 10G
* `SCCACHE_DIRECT` enable/disable preprocessor caching (see [the local doc](Local.md))
* `SCCACHE_LOCAL_RW_MODE` the mode that the cache will operate in (`READ_ONLY` or `READ_WRITE`)
* `SCCACHE_FILE_CLONE` enable reflink-based uncompressed disk cache (see [FileClone docs](FileClone.md))
* `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`.

#### s3 compatible

Expand Down
20 changes: 20 additions & 0 deletions src/cache/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,26 @@ fn write_uncompressed_entry(cache_root: &Path, key_dir: &Path, entry: CacheWrite
}
}

// If SCCACHE_FILE_CLONE_COMPRESS is set, spawn the command with the entry
// directory appended. This allows users to apply transparent compression
// (e.g., APFS compression via `applesauce compress -c lzfse`).
if let Ok(cmd) = std::env::var("SCCACHE_FILE_CLONE_COMPRESS") {
if let Some(parts) = shlex::split(&cmd) {
if let Some((program, args)) = parts.split_first() {
let mut command = std::process::Command::new(program);
command
.args(args)
.arg(&entry_dir)
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null());
match command.spawn() {
Ok(_) => trace!("Spawned file_clone compress: {} {:?}", cmd, entry_dir),
Err(e) => trace!("Failed to spawn file_clone compress: {}", e),
}
}
}
}

Ok(())
}

Expand Down
Loading