MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / build_runtime_cache

Function build_runtime_cache

src/pglite/base.rs:1816–1856  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1814}
1815
1816fn build_runtime_cache() -> Result<CachedRuntime> {
1817 let _phase = timing::phase("runtime.cache_install");
1818 let key = {
1819 let _phase = timing::phase("runtime.cache_key");
1820 runtime_cache_key()?
1821 };
1822 let dirs = ProjectDirs::from("dev", "pglite-oxide", "pglite-oxide")
1823 .context("could not resolve pglite-oxide cache directory")?;
1824 let cache_root = dirs.cache_dir().join("runtime");
1825 let _cache_lock = CacheLock::acquire(&cache_root.join(".locks").join(format!("{key}.lock")))?;
1826 let root = cache_root.join(&key);
1827 let paths = PglitePaths::with_root(root);
1828 {
1829 let _phase = timing::phase("runtime.cache_ensure_full");
1830 ensure_full_runtime(&paths)?;
1831 }
1832 let (module_path, _) = {
1833 let _phase = timing::phase("runtime.cache_locate_module");
1834 locate_runtime_module(&paths).ok_or_else(|| {
1835 anyhow!(
1836 "runtime missing: could not locate module under {} after cache install",
1837 paths.pgroot.display()
1838 )
1839 })?
1840 };
1841 if strict_asset_verification()?
1842 && let Some(manifest) = validated_embedded_pgdata_template_manifest()?
1843 {
1844 ensure_module_matches_template(&module_path, &manifest)?;
1845 }
1846 let runtime_root = module_path
1847 .parent()
1848 .and_then(Path::parent)
1849 .map(Path::to_path_buf)
1850 .unwrap_or_else(|| paths.runtime_root());
1851 {
1852 let _phase = timing::phase("runtime.cache_reset_mutable");
1853 reset_runtime_cache_mutable_state(&runtime_root)?;
1854 }
1855 Ok(CachedRuntime { runtime_root })
1856}
1857
1858fn reset_runtime_cache_mutable_state(runtime_root: &Path) -> Result<()> {
1859 for relative in ["base", "tmp", "dev/shm"] {

Callers 1

runtime_cacheFunction · 0.85

Calls 10

phaseFunction · 0.85
runtime_cache_keyFunction · 0.85
ensure_full_runtimeFunction · 0.85
locate_runtime_moduleFunction · 0.85
runtime_rootMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected