Skip to content

Commit ba8ccef

Browse files
authored
fix(mod_version): update links and tags on version accept by admin (#49)
1 parent f43f80a commit ba8ccef

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/endpoints/mod_versions.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,29 @@ pub async fn update_version(
474474

475475
let json = ModJson::from_zip(bytes, &version.download_link, true)?;
476476

477+
// Update links with data from mod.json
478+
if let Some(links) = json.links.clone() {
479+
mod_links::upsert(
480+
the_mod.id.as_str(),
481+
links.community,
482+
links.homepage,
483+
links.source,
484+
&mut tx,
485+
)
486+
.await?;
487+
} else {
488+
mod_links::upsert(the_mod.id.as_str(), None, None, None, &mut tx).await?;
489+
}
490+
491+
// Update tags with data from mod.json
492+
let tags = if let Some(tags) = &json.tags {
493+
mod_tags::parse_tag_list(tags, &mut tx).await?
494+
} else {
495+
vec![]
496+
};
497+
498+
mod_tags::update_for_mod(&the_mod.id, &tags, &mut tx).await?;
499+
477500
mods::update_with_json_moved(the_mod, json, &mut tx).await?;
478501
}
479502

src/mod_zip.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ pub async fn download_mod_hash_comp(
101101
let new_hash = sha256::digest(slice);
102102
if new_hash != hash {
103103
return Err(ApiError::BadRequest(format!(
104-
".geode hash mismatch: old {}, new {}",
105-
hash, new_hash,
104+
".geode hash mismatch: old {hash}, new {new_hash}",
106105
)));
107106
}
108107

0 commit comments

Comments
 (0)