shorebirdtech / updater

libupdater code for Shorebird
Other
66 stars 13 forks source link

fix: updating completing before patch failure will delete wrong patch #148

Closed eseidel closed 5 months ago

eseidel commented 5 months ago
    fn try_fall_back_to_last_booted_patch(&mut self) {
        // Not clear that next_boot_patch is the correct on here?
        // Could next_boot_patch have changed in between the time when we
        // started booting from when we failed to boot?
        // In Engine we read the "next boot patch"
        // Also trigger the background updater thread.
        // We try to boot from the next_boot_patch.
        // If it fails, we try to record the failure (does this wait on the lock held by the updater?)
        if let Some(next_boot_patch) = self.patches_state.next_boot_patch {

next_boot_patch is the wrong field to read in try_fall_back_to_last_booted_patch. We should write a test which does:

start_patch(1) update -> installs patch 2 fail_patch() and notice that it deletes the correct patch on disk (1) when trying to fail patch (1) and then presumably also boots from patch 2 next? (Probably we right now boot from no-patch next, but should infact boot from patch 2?). Do we end up currently orphaning patch 2?