You've already forked AstralRinth
forked from didirus/AstralRinth
Fix updating mod version if file hash is the same (#5138)
* Start fixing infinite update glitch * adjust app cache logic * more cache logic * cleanup * add v2 redirect * add v2 version file route to config
This commit is contained in:
@@ -1307,9 +1307,9 @@ impl CachedEntry {
|
||||
let variations =
|
||||
futures::future::try_join_all(filtered_keys.iter().map(
|
||||
|((loaders_key, game_version), hashes)| {
|
||||
fetch_json::<HashMap<String, Version>>(
|
||||
fetch_json::<HashMap<String, Vec<Version>>>(
|
||||
Method::POST,
|
||||
concat!(env!("MODRINTH_API_URL"), "version_files/update"),
|
||||
concat!(env!("MODRINTH_API_URL"), "version_files/update_many"),
|
||||
None,
|
||||
Some(serde_json::json!({
|
||||
"algorithm": "sha1",
|
||||
@@ -1330,28 +1330,30 @@ impl CachedEntry {
|
||||
&filtered_keys[index];
|
||||
|
||||
for hash in hashes {
|
||||
let version = variation.remove(hash);
|
||||
let versions = variation.remove(hash);
|
||||
|
||||
if let Some(version) = version {
|
||||
let version_id = version.id.clone();
|
||||
vals.push((
|
||||
CacheValue::Version(version).get_entry(),
|
||||
false,
|
||||
));
|
||||
if let Some(versions) = versions {
|
||||
for version in versions {
|
||||
let version_id = version.id.clone();
|
||||
vals.push((
|
||||
CacheValue::Version(version).get_entry(),
|
||||
false,
|
||||
));
|
||||
|
||||
vals.push((
|
||||
CacheValue::FileUpdate(CachedFileUpdate {
|
||||
hash: hash.clone(),
|
||||
game_version: game_version.clone(),
|
||||
loaders: loaders_key
|
||||
.split('+')
|
||||
.map(|x| x.to_string())
|
||||
.collect(),
|
||||
update_version_id: version_id,
|
||||
})
|
||||
.get_entry(),
|
||||
true,
|
||||
));
|
||||
vals.push((
|
||||
CacheValue::FileUpdate(CachedFileUpdate {
|
||||
hash: hash.clone(),
|
||||
game_version: game_version.clone(),
|
||||
loaders: loaders_key
|
||||
.split('+')
|
||||
.map(|x| x.to_string())
|
||||
.collect(),
|
||||
update_version_id: version_id,
|
||||
})
|
||||
.get_entry(),
|
||||
true,
|
||||
));
|
||||
}
|
||||
} else {
|
||||
vals.push((
|
||||
CacheValueType::FileUpdate.get_empty_entry(
|
||||
|
||||
@@ -1009,17 +1009,15 @@ impl Profile {
|
||||
initial_file.file_name
|
||||
);
|
||||
|
||||
let update_version_id = if let Some(update) = file_updates
|
||||
.iter()
|
||||
.find(|x| x.hash == hash.hash)
|
||||
.map(|x| x.update_version_id.clone())
|
||||
{
|
||||
if let Some(metadata) = &file {
|
||||
if metadata.version_id != update {
|
||||
Some(update)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
let update_version_id = if let Some(metadata) = &file {
|
||||
let update_ids: Vec<String> = file_updates
|
||||
.iter()
|
||||
.filter(|x| x.hash == hash.hash)
|
||||
.map(|x| x.update_version_id.clone())
|
||||
.collect();
|
||||
|
||||
if !update_ids.contains(&metadata.version_id) {
|
||||
update_ids.into_iter().next()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user