Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add node mirror/flavor to cache key #2638

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/backend/asdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use url::Url;

use crate::backend::external_plugin_cache::ExternalPluginCache;
use crate::backend::{ABackend, Backend, BackendList};
use crate::cache::CacheManager;
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::config::{Config, Settings};
use crate::default_shorthands::DEFAULT_SHORTHANDS;
Expand Down Expand Up @@ -56,26 +56,30 @@ impl AsdfBackend {
let toml = MisePluginToml::from_file(&toml_path).unwrap();
Self {
cache: ExternalPluginCache::default(),
remote_version_cache: CacheManager::new(
ba.cache_path.join("remote_versions-$KEY.msgpack.z"),
remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"),
)
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE)
.with_fresh_file(plugin_path.clone())
.with_fresh_file(plugin_path.join("bin/list-all")),
latest_stable_cache: CacheManager::new(
ba.cache_path.join("latest_stable-$KEY.msgpack.z"),
.with_fresh_file(plugin_path.join("bin/list-all"))
.build(),
latest_stable_cache: CacheManagerBuilder::new(
ba.cache_path.join("latest_stable.msgpack.z"),
)
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE)
.with_fresh_file(plugin_path.clone())
.with_fresh_file(plugin_path.join("bin/latest-stable")),
alias_cache: CacheManager::new(ba.cache_path.join("aliases-$KEY.msgpack.z"))
.with_fresh_file(plugin_path.join("bin/latest-stable"))
.build(),
alias_cache: CacheManagerBuilder::new(ba.cache_path.join("aliases.msgpack.z"))
.with_fresh_file(plugin_path.clone())
.with_fresh_file(plugin_path.join("bin/list-aliases")),
legacy_filename_cache: CacheManager::new(
ba.cache_path.join("legacy_filenames-$KEY.msgpack.z"),
.with_fresh_file(plugin_path.join("bin/list-aliases"))
.build(),
legacy_filename_cache: CacheManagerBuilder::new(
ba.cache_path.join("legacy_filenames.msgpack.z"),
)
.with_fresh_file(plugin_path.clone())
.with_fresh_file(plugin_path.join("bin/list-legacy-filenames")),
.with_fresh_file(plugin_path.join("bin/list-legacy-filenames"))
.build(),
plugin_path,
plugin: Box::new(AsdfPlugin::new(name.clone())),
repo_url: None,
Expand Down
9 changes: 5 additions & 4 deletions src/backend/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde_json::Deserializer;
use url::Url;

use crate::backend::{Backend, BackendType};
use crate::cache::CacheManager;
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::{Config, Settings};
Expand Down Expand Up @@ -113,10 +113,11 @@ impl Backend for CargoBackend {
impl CargoBackend {
pub fn from_arg(ba: BackendArg) -> Self {
Self {
remote_version_cache: CacheManager::new(
ba.cache_path.join("remote_versions-$KEY.msgpack.z"),
remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"),
)
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE),
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE)
.build(),
ba,
}
}
Expand Down
16 changes: 9 additions & 7 deletions src/backend/external_plugin_cache.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::backend::asdf::AsdfBackend;
use crate::cache::CacheManager;
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::config::Config;
use crate::dirs;
use crate::hash::hash_to_str;
Expand Down Expand Up @@ -32,15 +32,16 @@ impl ExternalPluginCache {
Some(key) => {
let config = Config::get();
let key = render_cache_key(&config, tv, key);
let filename = format!("{}-$KEY.msgpack.z", key);
let filename = format!("{}.msgpack.z", key);
tv.cache_path().join("list_bin_paths").join(filename)
}
None => tv.cache_path().join("list_bin_paths-$KEY.msgpack.z"),
None => tv.cache_path().join("list_bin_paths.msgpack.z"),
};
CacheManager::new(list_bin_paths_filename)
CacheManagerBuilder::new(list_bin_paths_filename)
.with_fresh_file(dirs::DATA.to_path_buf())
.with_fresh_file(plugin.plugin_path.clone())
.with_fresh_file(tv.install_path())
.build()
});
cm.get_or_try_init(fetch).cloned()
}
Expand All @@ -60,15 +61,16 @@ impl ExternalPluginCache {
let exec_env_filename = match &plugin.toml.exec_env.cache_key {
Some(key) => {
let key = render_cache_key(config, tv, key);
let filename = format!("{}-$KEY.msgpack.z", key);
let filename = format!("{}.msgpack.z", key);
tv.cache_path().join("exec_env").join(filename)
}
None => tv.cache_path().join("exec_env-$KEY.msgpack.z"),
None => tv.cache_path().join("exec_env.msgpack.z"),
};
CacheManager::new(exec_env_filename)
CacheManagerBuilder::new(exec_env_filename)
.with_fresh_file(dirs::DATA.to_path_buf())
.with_fresh_file(plugin.plugin_path.clone())
.with_fresh_file(tv.install_path())
.build()
});
cm.get_or_try_init(fetch).cloned()
}
Expand Down
9 changes: 5 additions & 4 deletions src/backend/go.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::Debug;

use crate::backend::{Backend, BackendType};
use crate::cache::CacheManager;
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::Settings;
Expand Down Expand Up @@ -92,10 +92,11 @@ impl Backend for GoBackend {
impl GoBackend {
pub fn from_arg(ba: BackendArg) -> Self {
Self {
remote_version_cache: CacheManager::new(
ba.cache_path.join("remote_versions-$KEY.msgpack.z"),
remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"),
)
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE),
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE)
.build(),
ba,
}
}
Expand Down
16 changes: 9 additions & 7 deletions src/backend/npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde_json::Value;
use std::fmt::Debug;

use crate::backend::{Backend, BackendType};
use crate::cache::CacheManager;
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::Config;
Expand Down Expand Up @@ -86,14 +86,16 @@ impl Backend for NPMBackend {
impl NPMBackend {
pub fn from_arg(ba: BackendArg) -> Self {
Self {
remote_version_cache: CacheManager::new(
ba.cache_path.join("remote_versions-$KEY.msgpack.z"),
remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"),
)
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE),
latest_version_cache: CacheManager::new(
ba.cache_path.join("latest_version-$KEY.msgpack.z"),
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE)
.build(),
latest_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("latest_version.msgpack.z"),
)
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE),
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE)
.build(),
ba,
}
}
Expand Down
16 changes: 9 additions & 7 deletions src/backend/pipx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::str::FromStr;
use versions::Versioning;

use crate::backend::{Backend, BackendType};
use crate::cache::CacheManager;
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::{Config, Settings};
Expand Down Expand Up @@ -119,14 +119,16 @@ impl Backend for PIPXBackend {
impl PIPXBackend {
pub fn from_arg(ba: BackendArg) -> Self {
Self {
remote_version_cache: CacheManager::new(
ba.cache_path.join("remote_versions-$KEY.msgpack.z"),
remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"),
)
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE),
latest_version_cache: CacheManager::new(
ba.cache_path.join("latest_version-$KEY.msgpack.z"),
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE)
.build(),
latest_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("latest_version.msgpack.z"),
)
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE),
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE)
.build(),
ba,
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/backend/spm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use url::Url;
use walkdir::WalkDir;

use crate::backend::{Backend, BackendType};
use crate::cache::CacheManager;
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::Settings;
Expand Down Expand Up @@ -87,10 +87,11 @@ impl Backend for SPMBackend {
impl SPMBackend {
pub fn from_arg(ba: BackendArg) -> Self {
Self {
remote_version_cache: CacheManager::new(
ba.cache_path.join("remote_versions-$KEY.msgpack.z"),
remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"),
)
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE),
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE)
.build(),
ba,
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/backend/ubi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::Debug;

use crate::backend::{Backend, BackendType};
use crate::cache::CacheManager;
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::{Config, Settings};
Expand Down Expand Up @@ -81,10 +81,11 @@ impl Backend for UbiBackend {
impl UbiBackend {
pub fn from_arg(ba: BackendArg) -> Self {
Self {
remote_version_cache: CacheManager::new(
ba.cache_path.join("remote_versions-$KEY.msgpack.z"),
remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"),
)
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE),
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE)
.build(),
ba,
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/backend/vfox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tokio::runtime::Runtime;
use url::Url;

use crate::backend::{ABackend, Backend, BackendList, BackendType};
use crate::cache::CacheManager;
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::config::{Config, Settings};
use crate::git::Git;
Expand Down Expand Up @@ -121,17 +121,19 @@ impl VfoxBackend {
let pathname = ba.short.to_kebab_case();
let plugin_path = dirs::PLUGINS.join(&pathname);
Self {
remote_version_cache: CacheManager::new(
ba.cache_path.join("remote_versions-$KEY.msgpack.z"),
remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"),
)
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE)
.with_fresh_file(dirs::DATA.to_path_buf())
.with_fresh_file(plugin_path.to_path_buf())
.with_fresh_file(ba.installs_path.to_path_buf()),
exec_env_cache: CacheManager::new(ba.cache_path.join("exec_env-$KEY.msgpack.z"))
.with_fresh_file(ba.installs_path.to_path_buf())
.build(),
exec_env_cache: CacheManagerBuilder::new(ba.cache_path.join("exec_env.msgpack.z"))
.with_fresh_file(dirs::DATA.to_path_buf())
.with_fresh_file(plugin_path.to_path_buf())
.with_fresh_file(ba.installs_path.to_path_buf()),
.with_fresh_file(ba.installs_path.to_path_buf())
.build(),
repo: OnceLock::new(),
ba,
vfox,
Expand Down
Loading
Loading