pub fn load_from_disk_or_default(path: &Path) -> OfficialIndexExpand description
What: Load an official package index from disk, tolerating missing or corrupt files.
Inputs:
path: File path to read the JSON index from.
Output:
- The deserialized index, or an empty
OfficialIndexwhen the file is missing, unreadable, or not valid index JSON.
Details:
- Convenience wrapper over
load_from_diskfor resilient startup paths (Pacsea’s original semantics): a corrupt cache should trigger a fresh fetch, not a startup error. The failure reason is logged at debug level.
§Example
use arch_toolkit::index::{fetch_official_index, load_from_disk_or_default};
use std::path::Path;
let mut index = load_from_disk_or_default(Path::new("official_index.json"));
if index.pkgs.is_empty() {
index = fetch_official_index()?;
}