Skip to main content

Module startup_cache

Module startup_cache 

Source
Expand description

Startup cache repair: keep the app’s cache directory usable before a plugin needs it.

Donor: ViewRight startup_cache.rs. A dangling symlink or a stray file where a cache directory belongs makes create_dir_all fail with AlreadyExists, which aborts plugins that expect the directory (tauri-plugin-http cookie cache). Cache content is disposable, so the bad entry is replaced with a real directory.

ensure_http_cache_dir resolves the platform user cache root (~/Library/Caches, %LOCALAPPDATA%, or $XDG_CACHE_HOME / ~/.cache) and repairs <root>/<identifier>. It needs no Tauri handle, so it can run before the Tauri builder starts.

Enums§

CacheDirOutcome
What a cache-directory repair did.

Functions§

ensure_cache_dir
Make path a usable directory, replacing a dangling symlink or a regular file.
ensure_http_cache_dir
Repair <user cache root>/<identifier> so a plugin can create its cookie or HTTP cache there. identifier is one path component (usually the bundle identifier): empty values, separators, . and .. are refused. The root is user_cache_root; an app whose Tauri resolves the cache directory differently (for example through dirs::cache_dir() or the Tauri path resolver) uses ensure_http_cache_dir_with.
ensure_http_cache_dir_with
ensure_http_cache_dir with a caller-supplied cache root, so the repaired directory is exactly the one the app’s Tauri resolves:
user_cache_root
The platform user cache root that Tauri and dirs agree on.