Skip to content

Commit

Permalink
fix: fix plugins/fs infinite loop on autoregen (#1029)
Browse files Browse the repository at this point in the history
* Created safety check for redundant autogenerations

* Accounted for empty file case, added .changes file

* Update plugins/fs/build.rs
  • Loading branch information
otamam818 authored Mar 6, 2024
1 parent ac520a2 commit 7358102
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/file-autogen-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"fs": patch
"fs-js": patch
---

Fix infinite loop on cargo build operations
7 changes: 5 additions & 2 deletions plugins/fs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,11 @@ permissions = [
]"###
);

std::fs::write(base_dirs.join(format!("{lower}.toml")), toml)
.unwrap_or_else(|e| panic!("unable to autogenerate ${upper}: {e}"));
let permission_path = base_dirs.join(format!("{lower}.toml"));
if toml != std::fs::read_to_string(&permission_path).unwrap_or_default() {
std::fs::write(permission_path, toml)
.unwrap_or_else(|e| panic!("unable to autogenerate ${lower}: {e}"));
}
}

tauri_plugin::Builder::new(COMMANDS)
Expand Down

0 comments on commit 7358102

Please sign in to comment.