mirror of
https://github.com/sergi0g/cup.git
synced 2025-11-08 13:13:49 -05:00
fix: ignore empty refresh interval
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use rustc_hash::FxHashMap;
|
||||
use serde::Deserialize;
|
||||
use serde::Deserializer;
|
||||
use std::env;
|
||||
use std::mem;
|
||||
use std::path::PathBuf;
|
||||
@@ -64,6 +65,7 @@ pub struct Config {
|
||||
pub agent: bool,
|
||||
pub ignore_update_type: UpdateType,
|
||||
pub images: ImageConfig,
|
||||
#[serde(deserialize_with = "empty_as_none")]
|
||||
pub refresh_interval: Option<String>,
|
||||
pub registries: FxHashMap<String, RegistryConfig>,
|
||||
pub servers: FxHashMap<String, String>,
|
||||
@@ -151,3 +153,15 @@ impl Default for Config {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
fn empty_as_none<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let s = String::deserialize(deserializer)?;
|
||||
if s.is_empty() {
|
||||
Ok(None)
|
||||
} else {
|
||||
Ok(Some(s))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user