diff --git a/Cargo.toml b/Cargo.toml index 2eeaf91..38c0c37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libfreemkv" -version = "0.20.2" +version = "0.20.3" edition = "2024" rust-version = "1.86" license = "AGPL-3.0-only" diff --git a/src/disc/patch.rs b/src/disc/patch.rs index 1805d1c..622503e 100644 --- a/src/disc/patch.rs +++ b/src/disc/patch.rs @@ -895,6 +895,18 @@ impl Disc { ); let mut bt_pos = backtrack_start; while bt_pos < backtrack_end { + // Honor cancellation inside the + // backtrack inner loop. A long + // backtrack span can run minutes + // of single-sector reads; without + // this check the outer halt only + // takes effect when control + // returns to the per-range loop. + if let Some(h) = &opts.halt { + if h.load(std::sync::atomic::Ordering::Relaxed) { + return Err(crate::error::Error::Halted); + } + } let span = // Backtrack always at count=1: this path // fills a gap that the main loop's damage-