fix #14740: linux update check and upload safety

- Linux: ask the feed for the windows-x86_64 entry only to learn the
  version; report it (the settings show the .deb hint) without storing a
  pending update or announcing it. install_update refuses off Windows.
- Background checks re-check is_due once the running lock is held.
- Check errors read "Update-Prüfung fehlgeschlagen: …".
- Settings: a failed follow-up getUpdate() never hides a found update; an
  unknown canSelfUpdate() shows it without an install button.
- An upload the CRM accepted but that could not be saved locally names
  the CRM id and is refused for re-upload until the app restarts.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-09 10:50:12 +01:00
co-authored by Claude Opus 5.5
parent 083edf32a2
commit a0f89454f9
4 changed files with 273 additions and 41 deletions
+48 -5
View File
@@ -164,6 +164,12 @@ pub struct AppState {
backend_key_lock: Mutex<()>,
/// Calls whose transcript is being uploaded; one upload per call.
uploading: Mutex<HashSet<CallId>>,
/// Calls whose transcript reached the CRM but could not be recorded
/// locally (`mark_uploaded` failed after a successful upload):
/// `claim_upload` refuses these for the rest of this run, so a retry
/// never creates a second copy at the CRM. In-memory only; a restart
/// forgets it (the row's `crm_transcript_id` is still empty then).
upload_confirmed_unsaved: Mutex<HashSet<CallId>>,
}
/// An upload reserved with [`AppState::claim_upload`]; released when
@@ -217,6 +223,7 @@ impl AppState {
.to_string(),
backend_key_lock: Mutex::new(()),
uploading: Mutex::new(HashSet::new()),
upload_confirmed_unsaved: Mutex::new(HashSet::new()),
}
}
@@ -342,16 +349,21 @@ impl AppState {
}
/// Reserves call `id` for one upload; released when the claim is
/// dropped. A second upload of the same call is refused meanwhile, and a
/// call that already carries a CRM transcript id is refused outright:
/// the CRM must never get a duplicate. Both checks happen while
/// `uploading` is locked, so a second upload can never slip in between
/// this check and the one upload it allows.
/// dropped. A second upload of the same call is refused meanwhile, and
/// so is a call that already carries a CRM transcript id — or one the
/// CRM confirmed but whose id could not be saved locally, see
/// [`AppState::note_upload_confirmed_but_unsaved`]: the CRM must never
/// get a duplicate. All three checks happen while `uploading` is
/// locked, so a second upload can never slip in between this check and
/// the one upload it allows.
pub fn claim_upload(&self, id: CallId) -> Result<UploadClaim<'_>, String> {
let mut uploading = lock(&self.uploading);
if uploading.contains(&id) {
return Err("Wird bereits hochgeladen".to_string());
}
if lock(&self.upload_confirmed_unsaved).contains(&id) {
return Err("Bereits hochgeladen".to_string());
}
if self.find_call(id)?.crm_transcript_id.is_some() {
return Err("Bereits hochgeladen".to_string());
}
@@ -364,6 +376,14 @@ impl AppState {
lock(&self.uploading).contains(&id)
}
/// Records that call `id`'s transcript reached the CRM, but saving that
/// locally (`mark_uploaded`) failed: [`AppState::claim_upload`] refuses
/// this call for the rest of the run, so a retry can never send the CRM
/// a second copy. In-memory only; see the field's doc comment.
pub fn note_upload_confirmed_but_unsaved(&self, id: CallId) {
lock(&self.upload_confirmed_unsaved).insert(id);
}
/// Changes and saves settings the app manages itself; saves only if
/// something changed.
fn update_settings(&self, change: impl FnOnce(&mut Settings)) -> Result<(), String> {
@@ -1643,6 +1663,29 @@ mod tests {
assert!(!f.state.is_uploading(id));
}
#[test]
fn an_upload_confirmed_but_unsaved_is_never_retried() {
// The CRM has the transcript, but mark_uploaded failed: the row
// itself still shows no crm_transcript_id.
let f = fixture();
let (id, _, _) = finished_call(&f, "a");
f.state.note_upload_confirmed_but_unsaved(id);
assert!(f
.state
.call_detail(id)
.unwrap()
.call
.item
.crm_transcript_id
.is_none());
assert_eq!(
f.state.claim_upload(id).err(),
Some("Bereits hochgeladen".to_string())
);
assert!(!f.state.is_uploading(id));
}
#[test]
fn an_upload_is_recorded_on_the_call() {
let f = fixture();