From f242632cfd920a7defe0422efb8455db0cc3016f Mon Sep 17 00:00:00 2001 From: mxdamien Date: Mon, 17 Jan 2022 22:39:57 +0100 Subject: [PATCH] Match file extensions against blacklist to avoid multiple rebuilds triggered by temporary files --- src/main.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main.rs b/src/main.rs index 6cdaa6fbb..c1635a06f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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; @@ -139,6 +141,24 @@ fn main() -> anyhow::Result<()> { notify::event::DataChange::Content, )) = event.kind { + let file_ext = event + .paths + .get(0) + .expect("File path missing in watch event") + .extension(); + + let black_list = HashSet::from([ + OsStr::new("swp"), + OsStr::new("tmp"), + OsStr::new("swx"), + ]); + + if let Some(ext) = file_ext { + if black_list.contains(ext) { + return; + } + } + let shape = match model.load(¶meters) { Ok(shape) => shape, Err(model::Error::Compile) => {