diff --git a/src/main.rs b/src/main.rs index 3716bb6..2087871 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,7 +65,12 @@ fn write_script_file_to_src(script_file: &String, cache_script_bin_name: String) if let Ok(Some(canonicalized_script_file)) = PathBuf::from(script_file) .canonicalize().map(|f| f.to_str().map(|f| f.to_string())) { let cache_script_bin_name_src = format!("{}.src", cache_script_bin_name); - if let Ok(_) = fs::write(&cache_script_bin_name_src, &format!("{}\n", canonicalized_script_file)) { + let src_content = fs::read_to_string(&cache_script_bin_name_src).ok(); + if src_content.as_ref().map(|c| c.contains(&canonicalized_script_file)).unwrap_or_else(|| false) { + return; + } + let new_src_content = src_content.unwrap_or_else(|| "".to_string()) + &format!("{}\n", canonicalized_script_file); + if let Ok(_) = fs::write(&cache_script_bin_name_src, &new_src_content) { debugging!("Write {} to {}", canonicalized_script_file, cache_script_bin_name_src); } }