feat: add unknown .mrpack install warning modal (#5942)

* Update modpack button copy

* Change outlined button style for standard buttons

* add unknown pack warning modal

* implementation

* Redo download toasts

* prepr

* improve hit area of window controls

* implement "don't show again"

* prepr

* duplicate modal ref declarations

* increase spacing of progress items

* address truman review
This commit is contained in:
Prospector
2026-04-29 09:53:10 -07:00
committed by GitHub
parent a80cc7e47b
commit dfb6814095
24 changed files with 1208 additions and 587 deletions

View File

@@ -108,6 +108,7 @@ pub struct CreatePackProfile {
pub icon: Option<PathBuf>, // the icon for the profile
pub icon_url: Option<String>, // the URL icon for a profile (ONLY USED FOR TEMPORARY PROFILES)
pub linked_data: Option<LinkedData>, // the linked project ID (mainly for modpacks)- used for updating
pub unknown_file: bool, // true when pack file isn't found on Modrinth via hash lookup
pub skip_install_profile: Option<bool>,
pub no_watch: Option<bool>,
}
@@ -123,6 +124,7 @@ impl Default for CreatePackProfile {
icon: None,
icon_url: None,
linked_data: None,
unknown_file: false,
skip_install_profile: Some(true),
no_watch: Some(false),
}
@@ -145,16 +147,16 @@ pub struct CreatePackDescription {
pub profile_path: String,
}
pub fn get_profile_from_pack(
pub async fn get_profile_from_pack(
location: CreatePackLocation,
) -> CreatePackProfile {
) -> crate::Result<CreatePackProfile> {
match location {
CreatePackLocation::FromVersionId {
project_id,
version_id,
title,
icon_url,
} => CreatePackProfile {
} => Ok(CreatePackProfile {
name: title,
icon_url,
linked_data: Some(LinkedData {
@@ -163,7 +165,7 @@ pub fn get_profile_from_pack(
locked: true,
}),
..Default::default()
},
}),
CreatePackLocation::FromFile { path } => {
let file_name = path
.file_stem()
@@ -171,10 +173,35 @@ pub fn get_profile_from_pack(
.to_string_lossy()
.to_string();
CreatePackProfile {
let state = State::get().await?;
let file_bytes = io::read(&path).await?;
let hash =
crate::util::fetch::sha1_async(bytes::Bytes::from(file_bytes))
.await?;
let is_known_file = match CachedEntry::get_file_many(
&[&hash],
Some(CacheBehaviour::StaleWhileRevalidateSkipOffline),
&state.pool,
&state.api_semaphore,
)
.await
{
Ok(files) => !files.is_empty(),
Err(err) => {
tracing::warn!(
"Failed to check Modrinth file hash for {}: {}",
path.display(),
err
);
false
}
};
Ok(CreatePackProfile {
name: file_name,
unknown_file: !is_known_file,
..Default::default()
}
})
}
}
}