Skip to content
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
5 changes: 4 additions & 1 deletion src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ pub static BASE_CACHE_KEYS: Lazy<Vec<String>> = Lazy::new(|| {

impl CacheManagerBuilder {
pub fn new(cache_file_path: impl AsRef<Path>) -> Self {
let settings = Settings::get();
let mut cache_keys = BASE_CACHE_KEYS.clone();
cache_keys.extend([settings.os().to_string(), settings.arch().to_string()]);
Self {
cache_file_path: cache_file_path.as_ref().to_path_buf(),
cache_keys: BASE_CACHE_KEYS.clone(),
cache_keys,
fresh_files: vec![],
fresh_duration: None,
}
Expand Down
6 changes: 5 additions & 1 deletion src/config/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use itertools::Itertools;
use serde::ser::Error;
use serde::{Deserialize, Deserializer};
use serde_derive::Serialize;
use std::env::consts::ARCH;
use std::env::consts::{ARCH, OS};
use std::fmt::{Debug, Display, Formatter};
use std::path::{Path, PathBuf};
use std::str::FromStr;
Expand Down Expand Up @@ -448,6 +448,10 @@ impl Settings {
Ok(shell_words::split(sa)?)
}

pub fn os(&self) -> &str {
self.os.as_deref().unwrap_or(OS)
}

pub fn arch(&self) -> &str {
self.arch.as_deref().unwrap_or(ARCH)
}
Expand Down
12 changes: 4 additions & 8 deletions src/plugins/core/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,16 @@ impl JavaPlugin {
pub fn new() -> Self {
let settings = Settings::get();
let ba = Arc::new(plugins::core::new_backend_arg("java"));
let java_metadata_ga_cache_filename =
format!("java_metadata_ga_{}_{}.msgpack.z", os(), arch(&settings));
let java_metadata_ea_cache_filename =
format!("java_metadata_ea_{}_{}.msgpack.z", os(), arch(&settings));
Self {
java_metadata_ea_cache: CacheManagerBuilder::new(
ba.cache_path.join(java_metadata_ea_cache_filename),
ba.cache_path.join("java_metadata_ea.msgpack.z"),
)
.with_fresh_duration(Settings::get().fetch_remote_versions_cache())
.with_fresh_duration(settings.fetch_remote_versions_cache())
.build(),
java_metadata_ga_cache: CacheManagerBuilder::new(
ba.cache_path.join(java_metadata_ga_cache_filename),
ba.cache_path.join("java_metadata_ga.msgpack.z"),
)
.with_fresh_duration(Settings::get().fetch_remote_versions_cache())
.with_fresh_duration(settings.fetch_remote_versions_cache())
.build(),
ba,
}
Expand Down
Loading