enhance: avoid failed hot-reload if backup file like .rs~ generate

This commit is contained in:
Jeremy Chen 2024-03-10 14:04:21 +08:00
parent 9241730d27
commit 8565bca11b

View file

@ -47,8 +47,13 @@ async fn setup_file_watcher<F: Fn() -> Result<BuildResult> + Send + 'static>(
for path in &e.paths {
// if this is not a rust file, rebuild the whole project
if path.extension().and_then(|p| p.to_str()) != Some("rs") {
let path_extension = path.extension().and_then(|p| p.to_str());
if path_extension != Some("rs") {
needs_full_rebuild = true;
// if backup file generated will impact normal hot-reload, so ignore it
if path_extension == Some("rs~") {
needs_full_rebuild = false;
}
break;
}