Implement interrupt handling for long-running commands and archive extraction
- Added an `interrupts` module to manage Ctrl-C signals and propagate them to child processes. - Refactored archive extraction functions to check for interrupts and handle them gracefully. - Introduced `copy_interruptibly` function to allow for interruptible copying of data. - Updated various source files to utilize the new interrupt handling functions, ensuring that commands and archive extractions can be interrupted by the user. - Added tests to verify the interrupt functionality during copying and tar extraction. - Introduced a new Meson option for generating HTML CLI documentation. - Enhanced the `PackageSpec` struct to support additional Rust LTO flags.
This commit is contained in:
@@ -296,6 +296,7 @@ pub fn prepare(spec: &PackageSpec, cache_dir: &Path, build_dir: &Path) -> Result
|
||||
let mut primary: Option<PathBuf> = None;
|
||||
|
||||
for (idx, src) in spec.sources().iter().enumerate() {
|
||||
crate::interrupts::check()?;
|
||||
let src_dir = prepare_one(spec, src, cache_dir, build_dir)
|
||||
.with_context(|| format!("Failed to prepare source #{}", idx + 1))?;
|
||||
if idx == 0 {
|
||||
@@ -409,6 +410,7 @@ fn prepare_one(
|
||||
fn copy_dir_recursive(src: &Path, dst: &Path) -> Result<()> {
|
||||
fs::create_dir_all(dst)?;
|
||||
for entry in WalkDir::new(src) {
|
||||
crate::interrupts::check()?;
|
||||
let entry = entry?;
|
||||
let rel = entry.path().strip_prefix(src).unwrap();
|
||||
let target = dst.join(rel);
|
||||
|
||||
Reference in New Issue
Block a user