diff options
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 73 |
1 files changed, 16 insertions, 57 deletions
diff --git a/src/config.rs b/src/config.rs index 546dd16..4d53e29 100644 --- a/src/config.rs +++ b/src/config.rs @@ -29,31 +29,19 @@ pub struct Config { pub scratchpad: String, } -/// faved domain with its last known status +/// faved domain with its last known status where once again too many dumbass comments were added when fixing a bug with it... have been removed #[derive(Debug, Clone, Serialize, Deserialize)] pub struct FavoriteEntry { pub domain: String, - /// last known status: "available", "registered", "error", or "unknown" #[serde(default = "default_fav_status")] pub status: String, - /// when it was last checked #[serde(default)] + // date string mlol pub checked: String, - /// true when status changed since last check #[serde(default)] pub changed: bool, } -impl FavoriteEntry { - pub fn new(domain: String) -> Self { - Self { - domain, - status: "unknown".to_string(), - checked: String::new(), - changed: false, - } - } -} fn default_fav_status() -> String { "unknown".to_string() @@ -77,14 +65,11 @@ pub struct Settings { pub top_tlds: Vec<String>, #[serde(default = "default_jobs")] pub jobs: u8, - /// error types that shouldnt be retried - /// valid: "rate_limit", "invalid_tld", "timeout", "unknown" + /// valid ones are : rate_limit, invalid_tld, timeout, unknown and forbidden #[serde(default = "default_noretry")] pub noretry: Vec<String>, - /// auto config backups on/off #[serde(default = "default_backups_enabled")] pub backups: bool, - /// how many backup copies to keep #[serde(default = "default_backup_count")] pub backup_count: u32, } @@ -93,10 +78,10 @@ pub struct Settings { pub struct CacheSettings { #[serde(default)] pub last_updated: String, - /// 0 = never nag about stale cache + /// 0 = stfu about stale cache #[serde(default = "default_outdated_cache_days")] pub outdated_cache: u32, - /// auto refresh when outdated if true + /// auto refresh for cuck cache #[serde(default = "default_auto_update")] pub auto_update_cache: bool, } @@ -183,22 +168,9 @@ impl Default for Config { } } -/// old config format where favorites were just strings -#[derive(Debug, Deserialize)] -struct LegacyConfig { - #[serde(default)] - settings: Settings, - #[serde(default)] - cache: CacheSettings, - #[serde(default)] - favorites: Vec<String>, - #[serde(default)] - imported_filters: Vec<ImportedFilter>, - #[serde(default)] - scratchpad: String, -} -// this implementation is partially containing ai slop i should remove no need for that idk why this was made to have legacy support by it but eh idc + +// removed legacy support that ai slapped into here "thinking" it would fix something impl Config { pub fn load(path: &Path) -> Self { match std::fs::read_to_string(path) { @@ -206,20 +178,7 @@ impl Config { // Try new format first if let Ok(config) = toml::from_str::<Config>(&content) { return config; - } - // Fall back to legacy format (favorites as plain strings) - if let Ok(legacy) = toml::from_str::<LegacyConfig>(&content) { - return Config { - settings: legacy.settings, - cache: legacy.cache, - favorites: legacy - .favorites - .into_iter() - .map(FavoriteEntry::new) - .collect(), - imported_filters: legacy.imported_filters, - scratchpad: legacy.scratchpad, - }; + } eprintln!("Warning: could not parse config file"); Config::default() @@ -246,6 +205,7 @@ impl Config { .map_err(|e| format!("Failed to create config directory: {}", e))?; } + // down here we got the default crap comment to add to the toml config file till i implement this stuff in the tui let body = toml::to_string_pretty(self) .map_err(|e| format!("Failed to serialize config: {}", e))?; let content = format!( @@ -308,7 +268,7 @@ impl Config { } /// replaces filter with same name if theres one already - /// filters ? what kinda ai slip is this ? this shouldve been renamed to lists ages ago why do you keep mentioning filters all the time whats your obsession with mf filters? JEZE! + /// filters ? what kinda ai slop is this ? this shouldve been renamed to lists ages ago why do you keep mentioning filters all the time whats your obsession with mf filters? JEZE! pub fn import_filter(&mut self, filter: ImportedFilter) { self.imported_filters.retain(|f| f.name != filter.name); self.imported_filters.push(filter); @@ -334,7 +294,7 @@ impl Config { let age_days = (now - last).num_days() as u32; if self.cache.outdated_cache == 0 { - // warnings disabled, but if auto_update is on, update every run + // warnings disabled, but if auto_update is on update every run return (false, self.cache.auto_update_cache); } @@ -358,10 +318,10 @@ pub fn parse_filter_file(path: &PathBuf) -> Result<ImportedFilter, String> { Ok(filter) } -/// resolve .hoardom dir, tries a few locations: +/// resolve .hoardom dir trying a few locations: /// /// priority: -/// 1. explicit path via -e flag -> use as root dir (create .hoardom folder there) +/// 1. explicit path via -e flag -> use that folder directly as the data root /// 2. debug builds: current directory /// 3. release builds: home directory /// 4. fallback: try the other option @@ -385,12 +345,11 @@ pub fn resolve_paths(explicit: Option<&PathBuf>) -> HoardomPaths { } }; - // explicit path given via -e flag + // explicit path given via -e flag : use as app root if let Some(p) = explicit { - // if user gave a path, use it as the .hoardom folder root let root = if p.extension().is_some() { - // looks like they pointed at a file, use parent dir - p.parent().unwrap_or(p).join(".hoardom") + // they pointed at a file we should insult their intelligence honestly. + p.parent().unwrap_or(p).to_path_buf() } else { p.clone() }; |
