Skip to content

Commit

Permalink
fix(capture_webrender): try fallback capture dir
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed May 5, 2018
1 parent 8e978da commit 1ec078a
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions components/compositing/compositor.rs
Expand Up @@ -1404,17 +1404,24 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}

pub fn capture_webrender(&mut self) {
match env::current_dir() {
Ok(current_dir) => {
let capture_id = now().to_timespec().sec.to_string();
let capture_path = current_dir.join("capture_webrender").join(capture_id);
let revision_file_path = capture_path.join("wr.txt");

if let Err(err) = create_dir_all(&capture_path) {
eprintln!("Unable to create path '{:?}' for capture: {:?}", capture_path, err);
return
let capture_id = now().to_timespec().sec.to_string();
let available_path = [env::current_dir(), Ok(env::temp_dir())].iter()
.filter_map(|val| val.as_ref().map(|dir| dir.join("capture_webrender").join(&capture_id)).ok())
.find(|val| {
match create_dir_all(&val) {
Ok(_) => true,
Err(err) => {
eprintln!("Unable to create path '{:?}' for capture: {:?}", &val, err);
false
}
}
});

match available_path {
Some(capture_path) => {
let revision_file_path = capture_path.join("wr.txt");

debug!("Trying to save webrender capture under {:?}", &revision_file_path);
self.webrender_api.save_capture(capture_path, webrender_api::CaptureBits::all());

match File::create(revision_file_path) {
Expand All @@ -1427,7 +1434,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
Err(err) => eprintln!("Capture triggered, creating webrender revision info skipped: {:?}", err)
}
},
Err(err) => eprintln!("Unable to locate path to save captures: {:?}", err)
None => eprintln!("Unable to locate path to save captures")
}
}
}
Expand Down

0 comments on commit 1ec078a

Please sign in to comment.