Bug 1433932: Avoid crashing on failing to save a capture. r=nical,kats

MozReview-Commit-ID: ARj9ww2F3gx
This commit is contained in:
Dzmitry Malyshau 2018-02-08 10:49:28 -05:00
Родитель 5852b9f1d6
Коммит d2d9759d7b
1 изменённых файлов: 14 добавлений и 8 удалений

Просмотреть файл

@ -1164,20 +1164,26 @@ pub extern "C" fn wr_api_capture(
path: *const c_char,
bits_raw: u32,
) {
use std::fs::File;
use std::fs::{File, create_dir_all};
use std::io::Write;
let cstr = unsafe { CStr::from_ptr(path) };
let path = PathBuf::from(&*cstr.to_string_lossy());
let revision_path = path.join("wr.txt");
let _ = create_dir_all(&path);
match File::create(path.join("wr.txt")) {
Ok(mut file) => {
let revision = include_bytes!("../revision.txt");
file.write(revision).unwrap();
}
Err(e) => {
println!("Unable to create path '{:?}' for capture: {:?}", path, e);
return
}
}
let bits = CaptureBits::from_bits(bits_raw as _).unwrap();
dh.api.save_capture(path, bits);
let revision = include_bytes!("../revision.txt");
File::create(revision_path)
.unwrap()
.write(revision)
.unwrap();
}
#[cfg(target_os = "windows")]