fix: 修复自动同步后误报内容更新
Axolotl desktop CI / guardrails (push) Waiting to run
Repository checks / typos (push) Waiting to run
Repository checks / tombi (push) Waiting to run
Rust checks / shear (push) Waiting to run
Sync source to CNB / Sync Git ref (push) Skipped

This commit is contained in:
AxTps committed 2026-10-24 18:46:54 +08:00
1 parent a9e43e5bab
commit a2afce2405
1 file changed
+26 -2
@@ -216,9 +216,33 @@ async fn modrinth_update_candidates(
.get(&file.id) .get(&file.id)
.map(Vec::as_slice) .map(Vec::as_slice)
.unwrap_or_default(); .unwrap_or_default();
// A file whose provider release tracking was invalidated (e.g. by an
// external sync replacing the jar) no longer carries a release id. In
// that case the SHA1 lookup below may resolve to an unrelated project
// or to a different version of the same project, which would surface a
// bogus "update available" right after a sync. Only trust the hash
// lookup when it resolves to the same project we already track.
let recorded_project_id = provider_refs.iter().find_map(|reference| {
match reference {
ContentProviderRef::Modrinth { project_id, .. } => {
Some(project_id.as_str())
}
ContentProviderRef::CurseForge { .. }
| ContentProviderRef::McArchive { .. } => None,
}
});
let Some(current_version_id) =
installed_modrinth_version_id(provider_refs).or_else(|| {
if recorded_project_id == Some(metadata.project_id.as_str()) {
ModrinthVersionId::new(metadata.version_id.to_string()).ok()
} else {
None
}
})
else {
continue;
};
let project_id = ModrinthProjectId::new(metadata.project_id.clone())?; let project_id = ModrinthProjectId::new(metadata.project_id.clone())?;
let current_version_id = installed_modrinth_version_id(provider_refs)
.unwrap_or(ModrinthVersionId::new(metadata.version_id.clone())?);
candidates.push(UpdateCandidate { candidates.push(UpdateCandidate {
entry: context.entries_by_file_id.get(&file.id).cloned(), entry: context.entries_by_file_id.get(&file.id).cloned(),
file: file.clone(), file: file.clone(),