mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-08-07 01:33:52 +00:00
fix: stabilize validation branch checks
This commit is contained in:
parent
d8ab300748
commit
ea8811bf8e
2 changed files with 11 additions and 1 deletions
|
|
@ -53,7 +53,7 @@ impl Cache {
|
|||
};
|
||||
let age = Utc::now().signed_duration_since(entry.fetched_at);
|
||||
if age
|
||||
> chrono::Duration::from_std(Duration::from_secs(entry.ttl_secs))
|
||||
>= chrono::Duration::from_std(Duration::from_secs(entry.ttl_secs))
|
||||
.map_err(|e| IdxError::CacheMiss(e.to_string()))?
|
||||
{
|
||||
return Ok(None);
|
||||
|
|
@ -185,6 +185,11 @@ impl Cache {
|
|||
}
|
||||
|
||||
pub fn cache_dir() -> Result<PathBuf, IdxError> {
|
||||
if let Ok(dir) = std::env::var("XDG_CACHE_HOME")
|
||||
&& !dir.is_empty()
|
||||
{
|
||||
return Ok(PathBuf::from(dir).join("idx"));
|
||||
}
|
||||
ProjectDirs::from("", "", "idx")
|
||||
.map(|d| d.cache_dir().to_path_buf())
|
||||
.ok_or_else(|| IdxError::ConfigError("unable to resolve cache dir".to_string()))
|
||||
|
|
|
|||
|
|
@ -197,6 +197,11 @@ pub fn default_config_toml() -> String {
|
|||
}
|
||||
|
||||
pub fn config_path() -> Result<PathBuf, IdxError> {
|
||||
if let Ok(dir) = std::env::var("XDG_CONFIG_HOME")
|
||||
&& !dir.is_empty()
|
||||
{
|
||||
return Ok(PathBuf::from(dir).join("idx").join("config.toml"));
|
||||
}
|
||||
ProjectDirs::from("", "", "idx")
|
||||
.map(|d| d.config_dir().join("config.toml"))
|
||||
.ok_or_else(|| IdxError::ConfigError("unable to resolve config dir".to_string()))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue