Skip to content

Commit e5a5663

Browse files
authored
fix: unsupported content destination error on modpack install (#8144)
1 parent 5d4369a commit e5a5663

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

‎packages/app-lib/src/state/instance_types.rs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,19 @@ impl ProjectType {
171171
}
172172
}
173173

174+
pub fn get_from_version_file(
175+
loaders: Vec<String>,
176+
file_name: &str,
177+
) -> Option<Self> {
178+
let is_zip = Path::new(file_name)
179+
.extension()
180+
.is_some_and(|ext| ext.eq_ignore_ascii_case("zip"));
181+
if is_zip && loaders.iter().any(|x| x == "datapack") {
182+
return Some(ProjectType::DataPack);
183+
}
184+
Self::get_from_loaders(loaders)
185+
}
186+
174187
pub fn get_from_parent_folder(path: impl AsRef<Path>) -> Option<Self> {
175188
match path
176189
.as_ref()

‎packages/app-lib/src/state/instances/commands/apply_content_install.rs‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,19 @@ pub(crate) async fn switch_project_version_with_dependencies(
248248
.ok_or(ErrorKind::InputError(format!(
249249
"unable to install version id {version_id}, not found"
250250
)))?;
251-
let content_type = ProjectType::get_from_loaders(version.loaders.clone())
252-
.map(ContentType::from)
253-
.unwrap_or(ContentType::Mod);
251+
let primary_file_name = version
252+
.files
253+
.iter()
254+
.find(|file| file.primary)
255+
.or_else(|| version.files.first())
256+
.map(|file| file.filename.as_str())
257+
.unwrap_or_default();
258+
let content_type = ProjectType::get_from_version_file(
259+
version.loaders.clone(),
260+
primary_file_name,
261+
)
262+
.map(ContentType::from)
263+
.unwrap_or(ContentType::Mod);
254264
let plan = resolve_install_plan(
255265
instance_id,
256266
InstanceInstallProjectRequest {
@@ -433,8 +443,11 @@ pub(crate) async fn download_project_version_with_progress(
433443
progress,
434444
)
435445
.await?;
436-
let project_type = ProjectType::get_from_loaders(version.loaders.clone())
437-
.ok_or(ErrorKind::InputError(format!(
446+
let project_type = ProjectType::get_from_version_file(
447+
version.loaders.clone(),
448+
&file.filename,
449+
)
450+
.ok_or(ErrorKind::InputError(format!(
438451
"unable to infer project type for version {version_id}"
439452
)))?;
440453
let project_id = version.project_id.clone();

0 commit comments

Comments
 (0)