enhance: avoid failed hot-reload if backup file like .rs~ generate (#2048)

(cherry picked from commit 8565bca11b)

Co-authored-by: Jeremy Chen <jeremychen@djeremychen.com>
This commit is contained in:
JeremyChen 2024-03-11 22:30:25 +08:00 committed by GitHub
parent 60235ac06b
commit 70f97ec787
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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;
}