mirror of
https://github.com/freemkv/freemkv-unlock.git
synced 2026-10-07 18:13:11 +00:00
fix(mt1959): run_init returns Ok once load_firmware confirms the unlock (D10)
load_firmware returns Ok only after its own do_unlock succeeded. run_init then slept 10 s and re-ran do_unlock, and on attempt 2 fell out of the loop returning Err(last_err), discarding a real unlock. Return Ok at once; the firmware upload itself is unchanged (stop-design-v5 §1 D10, ST-D10).
This commit is contained in:
@@ -291,8 +291,15 @@ impl Mt1959 {
|
||||
);
|
||||
return Err(e);
|
||||
}
|
||||
// Every exit below returns or overwrites `last_err` with the reload's error.
|
||||
Err(e) => {
|
||||
last_err = e;
|
||||
tracing::debug!(
|
||||
target: "freemkv::disc",
|
||||
phase = "mt1959_unlock_failed_reloading",
|
||||
attempt,
|
||||
error = %e,
|
||||
"unlock failed; reloading firmware"
|
||||
);
|
||||
let loaded = if self.mode == MODE_A {
|
||||
variant_a::load_firmware(self, scsi)
|
||||
} else {
|
||||
@@ -320,10 +327,18 @@ impl Mt1959 {
|
||||
last_err = e;
|
||||
continue;
|
||||
}
|
||||
// D10 (stop-design-v5 §1): "`run_init` must `return Ok(())` as soon as
|
||||
// `load_firmware` confirms the unlock" — its own do_unlock already did.
|
||||
// Looping re-ran it after a 10 s settle and discarded it on attempt 2.
|
||||
Ok(()) => {
|
||||
// Firmware upload resets the drive. Give it time to
|
||||
// fully recover before retrying unlock.
|
||||
std::thread::sleep(std::time::Duration::from_secs(10));
|
||||
tracing::debug!(
|
||||
target: "freemkv::disc",
|
||||
phase = "mt1959_unlock_ok_after_upload",
|
||||
attempt,
|
||||
unlocked = self.unlocked,
|
||||
"MT1959 unlock confirmed by the firmware upload"
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user