data,apt/release,distro_info,new: replace lazy_static with LazyLock
Unify the lazily-initialized statics on std::sync::LazyLock, which the newer code already uses: the embed_data! macro expands to a plain static now, which also removes the visibility-forwarding workaround the lazy_static! matcher forced on it (the @expand arm wrapping vis in parentheses), and the 'static ref' spelling is kept at the call sites. distro_info's HTTP client, the apt keyring cache and the new-template registry follow the same pattern.
This commit is contained in:
+5
-6
@@ -45,7 +45,6 @@
|
||||
//! keyserver responses are armored) are dearmored in-process, so no `gpg`
|
||||
//! binary is needed.
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use log::{debug, warn};
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
@@ -53,6 +52,7 @@ use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::LazyLock;
|
||||
use std::sync::Mutex;
|
||||
use std::sync::PoisonError;
|
||||
|
||||
@@ -793,11 +793,10 @@ async fn fetch_optional(url: &str) -> Option<Vec<u8>> {
|
||||
None
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
/// Downloaded keyrings, keyed by URL: keyrings are small but would
|
||||
/// otherwise be re-downloaded once per series/pocket lookup
|
||||
static ref KEYRING_CACHE: Mutex<HashMap<String, Vec<u8>>> = Mutex::new(HashMap::new());
|
||||
}
|
||||
/// Downloaded keyrings, keyed by URL: keyrings are small but would
|
||||
/// otherwise be re-downloaded once per series/pocket lookup
|
||||
static KEYRING_CACHE: LazyLock<Mutex<HashMap<String, Vec<u8>>>> =
|
||||
LazyLock::new(|| Mutex::new(HashMap::new()));
|
||||
|
||||
/// Read the keyring cache, ignoring poisoning (the map is only corrupted on
|
||||
/// panics, in which case a fresh map is just as good)
|
||||
|
||||
Reference in New Issue
Block a user