Skip to content

Commit

Permalink
Match file extensions against blacklist to avoid multiple rebuilds tr…
Browse files Browse the repository at this point in the history
…iggered by temporary files
  • Loading branch information
mxdamien committed Jan 17, 2022
1 parent 84999cd commit c857ca7
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ mod mesh;
mod model;
mod window;

use std::collections::HashSet;
use std::ffi::OsStr;
use std::{collections::HashMap, sync::mpsc, time::Instant};

use futures::executor::block_on;
Expand Down Expand Up @@ -139,27 +141,29 @@ fn main() -> anyhow::Result<()> {
notify::event::DataChange::Content,
)) = event.kind
{
let shape = match model.load(&parameters) {
Ok(shape) => shape,
Err(model::Error::Compile) => {
// It would be better to display an error in the UI,
// where the user can actually see it. Issue:
// https://github.com/hannobraun/fornjot/issues/30
println!("Error compiling model");
return;
match HashSet::from([OsStr::new("swp"), OsStr::new("tmp")])
.get(&event.paths[0].extension().unwrap())
{
Some(_value) => {
// nop
}
Err(err) => {
panic!("Error reloading model: {:?}", err);
None => {
let shape = match model.load(&parameters) {
Ok(shape) => shape,
Err(model::Error::Compile) => {
// It would be better to display an error in the UI,
// where the user can actually see it. Issue:
// https://github.com/hannobraun/fornjot/issues/30
println!("Error compiling model");
return;
}
Err(err) => {
panic!("Error reloading model: {:?}", err);
}
};
watcher_tx.send(shape).unwrap();
}
};

// This will panic, if the other end is disconnected, which is
// probably the result of a panic on that thread, or the
// application is being shut down.
//
// Either way, not much we can do about it here, except maybe to
// provide a better error message in the future.
watcher_tx.send(shape).unwrap();
}
}
},
)?;
Expand Down

0 comments on commit c857ca7

Please sign in to comment.