feat: add shared meta dir for downloads, skip cached

This commit is contained in:
objz committed 2025-08-09 15:46:08 +02:00
1 parent 6ff8ae64d5
commit abacb830bc
8 files changed
+148 -35

No files matched your search

+24
View File
@@ -18,6 +18,8 @@ impl Default for General {
pub struct Paths {
#[serde(default = "default_instances_dir")]
pub instances_dir: String,
#[serde(default = "default_meta_dir")]
pub meta_dir: String,
pub java_path: Option<String>,
}
@@ -25,10 +27,15 @@ fn default_instances_dir() -> String {
"~/.local/share/mcl/instances".to_string()
}
fn default_meta_dir() -> String {
"~/.local/share/mcl/meta".to_string()
}
impl Default for Paths {
fn default() -> Self {
Paths {
instances_dir: default_instances_dir(),
meta_dir: default_meta_dir(),
java_path: None,
}
}
@@ -51,6 +58,23 @@ impl Paths {
}
std::path::PathBuf::from(raw)
}
pub fn resolve_meta_dir(&self) -> std::path::PathBuf {
let raw = &self.meta_dir;
if let Some(stripped) = raw.strip_prefix("~/") {
return match dirs_next::home_dir() {
Some(home) => home.join(stripped),
None => std::path::PathBuf::from(raw),
};
}
if raw == "~" {
return match dirs_next::home_dir() {
Some(home) => home,
None => std::path::PathBuf::from(raw),
};
}
std::path::PathBuf::from(raw)
}
}
#[derive(Debug, Deserialize)]