зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1433932: Avoid crashing on failing to save a capture. r=nical,kats
MozReview-Commit-ID: ARj9ww2F3gx
This commit is contained in:
Родитель
5852b9f1d6
Коммит
d2d9759d7b
|
@ -1164,20 +1164,26 @@ pub extern "C" fn wr_api_capture(
|
||||||
path: *const c_char,
|
path: *const c_char,
|
||||||
bits_raw: u32,
|
bits_raw: u32,
|
||||||
) {
|
) {
|
||||||
use std::fs::File;
|
use std::fs::{File, create_dir_all};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
let cstr = unsafe { CStr::from_ptr(path) };
|
let cstr = unsafe { CStr::from_ptr(path) };
|
||||||
let path = PathBuf::from(&*cstr.to_string_lossy());
|
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();
|
let bits = CaptureBits::from_bits(bits_raw as _).unwrap();
|
||||||
dh.api.save_capture(path, bits);
|
dh.api.save_capture(path, bits);
|
||||||
|
|
||||||
let revision = include_bytes!("../revision.txt");
|
|
||||||
File::create(revision_path)
|
|
||||||
.unwrap()
|
|
||||||
.write(revision)
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
|
Загрузка…
Ссылка в новой задаче