fixes: post content tab release issues (#5566)
* fix: migrate old cache entries for CachedFileUpdate * feat: toggle goofy fix + switch version reimpl in app and panel * fix: multimc detection * fix: add tie breaker for sorting * feat: toggle hover state * fix: lint
This commit is contained in:
@@ -171,7 +171,9 @@ pub fn get_default_launcher_path(
|
||||
r#type: ImportLauncherType,
|
||||
) -> Option<PathBuf> {
|
||||
let path = match r#type {
|
||||
ImportLauncherType::MultiMC => None, // multimc data is *in* app dir
|
||||
ImportLauncherType::MultiMC => {
|
||||
return find_multimc_path();
|
||||
}
|
||||
ImportLauncherType::PrismLauncher => {
|
||||
Some(dirs::data_dir()?.join("PrismLauncher"))
|
||||
}
|
||||
@@ -195,6 +197,54 @@ pub fn get_default_launcher_path(
|
||||
if path.exists() { Some(path) } else { None }
|
||||
}
|
||||
|
||||
/// Searches common locations for a MultiMC installation.
|
||||
/// MultiMC stores data in its own application directory (not a standard data dir)
|
||||
fn find_multimc_path() -> Option<PathBuf> {
|
||||
let mut candidates: Vec<PathBuf> = Vec::new();
|
||||
|
||||
// Linux/macOS: ~/.local/share/multimc is the typical location
|
||||
if let Some(data_dir) = dirs::data_dir() {
|
||||
candidates.push(data_dir.join("multimc"));
|
||||
candidates.push(data_dir.join("MultiMC"));
|
||||
}
|
||||
|
||||
// Windows: check common extraction locations
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
if let Some(home) = dirs::home_dir() {
|
||||
candidates.push(home.join("MultiMC"));
|
||||
candidates.push(home.join("Desktop").join("MultiMC"));
|
||||
candidates.push(home.join("Downloads").join("MultiMC"));
|
||||
}
|
||||
candidates.push(PathBuf::from("C:\\MultiMC"));
|
||||
if let Some(program_files) =
|
||||
std::env::var_os("ProgramFiles").map(PathBuf::from)
|
||||
{
|
||||
candidates.push(program_files.join("MultiMC"));
|
||||
}
|
||||
if let Some(program_files_x86) =
|
||||
std::env::var_os("ProgramFiles(x86)").map(PathBuf::from)
|
||||
{
|
||||
candidates.push(program_files_x86.join("MultiMC"));
|
||||
}
|
||||
}
|
||||
|
||||
// macOS: MultiMC is a .app bundle with data inside MultiMC.app/Data/
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
candidates.push(PathBuf::from("/Applications/MultiMC.app/Data"));
|
||||
if let Some(home) = dirs::home_dir() {
|
||||
candidates.push(
|
||||
home.join("Applications").join("MultiMC.app").join("Data"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
candidates
|
||||
.into_iter()
|
||||
.find(|p| p.join("multimc.cfg").exists())
|
||||
}
|
||||
|
||||
/// Checks if this PathBuf is a valid instance for the given launcher type
|
||||
|
||||
#[tracing::instrument]
|
||||
|
||||
@@ -252,7 +252,7 @@ pub struct SearchResultV3 {
|
||||
pub total_hits: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[derive(Serialize, Clone, Debug)]
|
||||
pub struct CachedFileUpdate {
|
||||
pub hash: String,
|
||||
pub game_version: String,
|
||||
@@ -260,6 +260,39 @@ pub struct CachedFileUpdate {
|
||||
pub update_version_id: String,
|
||||
}
|
||||
|
||||
/// Migrates old cache entries that stored `"loader": "forge"` (singular string)
|
||||
/// to the current `"loaders": ["forge"]` (array) format.
|
||||
/// SEE: https://github.com/modrinth/code/issues/5562
|
||||
impl<'de> serde::Deserialize<'de> for CachedFileUpdate {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
#[derive(Deserialize)]
|
||||
struct Helper {
|
||||
hash: String,
|
||||
game_version: String,
|
||||
#[serde(default)]
|
||||
loaders: Option<Vec<String>>,
|
||||
#[serde(default)]
|
||||
loader: Option<String>,
|
||||
update_version_id: String,
|
||||
}
|
||||
|
||||
let helper = Helper::deserialize(deserializer)?;
|
||||
let loaders = helper.loaders.unwrap_or_else(|| {
|
||||
helper.loader.map(|l| vec![l]).unwrap_or_default()
|
||||
});
|
||||
|
||||
Ok(CachedFileUpdate {
|
||||
hash: helper.hash,
|
||||
game_version: helper.game_version,
|
||||
loaders,
|
||||
update_version_id: helper.update_version_id,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct CachedFileHash {
|
||||
pub path: String,
|
||||
|
||||
@@ -577,7 +577,10 @@ async fn profile_files_to_content_items(
|
||||
.as_ref()
|
||||
.map(|p| p.title.as_str())
|
||||
.unwrap_or(&b.file_name);
|
||||
name_a.to_lowercase().cmp(&name_b.to_lowercase())
|
||||
name_a
|
||||
.to_lowercase()
|
||||
.cmp(&name_b.to_lowercase())
|
||||
.then_with(|| a.file_name.cmp(&b.file_name))
|
||||
});
|
||||
|
||||
Ok(items)
|
||||
@@ -765,7 +768,10 @@ pub async fn dependencies_to_content_items(
|
||||
.as_ref()
|
||||
.map(|p| p.title.as_str())
|
||||
.unwrap_or(&b.file_name);
|
||||
name_a.to_lowercase().cmp(&name_b.to_lowercase())
|
||||
name_a
|
||||
.to_lowercase()
|
||||
.cmp(&name_b.to_lowercase())
|
||||
.then_with(|| a.file_name.cmp(&b.file_name))
|
||||
});
|
||||
|
||||
Ok(items)
|
||||
|
||||
Reference in New Issue
Block a user