fix(content): stop dropping update labels

Update labels disappeared at random and only came back after switching
instances, and mods installed from a modpack never got one.

- display no longer requires the snapshot inventory to match the manifest
  exactly; a single changed file wiped every label in the instance even
  though each update is keyed by its exact installed version
- a finished scan is applied instead of discarded when the manifest moved
  on in the meantime, and the pending queue no longer leaks or replays
  stale snapshots over newer ones
- compare versions by publish date and ask the provider for the installed
  version when it is missing from the compatible list, which is the normal
  case for modpack pinned files; also fixes the modpack update label
- keep known updates for checks that failed so an offline scan no longer
  overwrites a good cache
- rescan only when the inventory changed or the snapshot is older than
  30 minutes, with one pooled http client per scan instead of one per mod
This commit is contained in:
objz committed 2026-08-15 21:24:51 +02:00
1 parent 6155236a4c
commit 4ce081d6ed
7 files changed
+223 -72

No files matched your search

+23 -32
View File
@@ -402,19 +402,23 @@ impl App {
.instances_dir
.join(&result.instance_name),
);
self.content_update_snapshot =
let cached =
crate::instance::content::updates::UpdateSnapshot::load(&paths.content_updates())
.filter(|snapshot| {
snapshot.applies_to(&selected) && snapshot.matches_manifest(&result.manifest)
})
.map(|snapshot| (result.instance_name.clone(), snapshot));
.filter(|snapshot| snapshot.applies_to(&selected));
let stale = cached
.as_ref()
.is_none_or(|snapshot| snapshot.is_stale(&result.manifest));
self.content_update_snapshot =
cached.map(|snapshot| (result.instance_name.clone(), snapshot));
self.content_manifest = Some((result.instance_name.clone(), result.manifest.clone()));
self.apply_content_update_snapshot();
crate::instance::content::updates::spawn(
selected,
result.manifest,
paths.content_updates(),
);
if stale {
crate::instance::content::updates::spawn(
selected,
result.manifest,
paths.content_updates(),
);
}
}
fn apply_cached_content_manifest(&mut self) {
@@ -458,36 +462,30 @@ impl App {
};
let snapshot = match crate::instance::content::updates::PENDING_UPDATE_SNAPSHOTS.lock() {
Ok(mut pending) => {
pending.retain(|pending| {
pending.instance_name != selected.name
|| pending.instance_created == selected.created
});
pending
let latest = pending
.iter()
.rposition(|pending| {
pending.instance_name == selected.name
&& pending.instance_created == selected.created
})
.map(|index| pending.remove(index))
.map(|index| pending.remove(index));
// every scan also writes its result to disk, so whatever is left
// here is recovered on the next reconciliation of that instance
pending.clear();
latest
}
Err(_) => return,
};
let Some(snapshot) = snapshot else {
return;
};
let current_manifest = self
.content_manifest
.as_ref()
.filter(|(name, _)| name == &snapshot.instance_name)
.map(|(_, manifest)| manifest);
if current_manifest.is_none_or(|manifest| !snapshot.snapshot.matches_manifest(manifest)) {
return;
}
self.content_update_snapshot = Some((snapshot.instance_name, snapshot.snapshot));
self.apply_content_update_snapshot();
}
fn apply_content_update_snapshot(&mut self) {
// matched per entry by exact installed version, so a snapshot that no
// longer covers the whole manifest still labels everything it does cover
let snapshot = self
.content_update_snapshot
.as_ref()
@@ -495,14 +493,7 @@ impl App {
self.instances_state
.selected_instance()
.filter(|instance| instance.name == *name && snapshot.applies_to(instance))
.and_then(|_| {
self.content_manifest
.as_ref()
.filter(|(manifest_name, manifest)| {
manifest_name == name && snapshot.matches_manifest(manifest)
})
.map(|_| snapshot)
})
.map(|_| snapshot)
});
self.mods_state.apply_update_snapshot(snapshot);
self.resource_packs_state.apply_update_snapshot(snapshot);