diff --git a/docs/Configuration.md b/docs/Configuration.md index 29fdfcb00..dd95462cb 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -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 diff --git a/src/cache/disk.rs b/src/cache/disk.rs index 9f71097fa..8e64f0012 100644 --- a/src/cache/disk.rs +++ b/src/cache/disk.rs @@ -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(()) }