Skip to main content

ensure_cache_dir

Function ensure_cache_dir 

Source
pub fn ensure_cache_dir(path: &Path) -> Result<()>
Expand description

Creates the cache directory if it doesn’t exist and excludes it from backups.

This function:

  1. Creates the directory and all parent directories if they don’t exist
  2. Creates a CACHEDIR.TAG file to exclude from backup tools (borg, restic, etc.)
  3. On macOS, marks the directory as excluded from Time Machine

This is idempotent - calling it multiple times on the same directory is safe.