From 735810237e21504a027a65a7b3c25fd7e594288a Mon Sep 17 00:00:00 2001 From: Tahmin Ahmed <68072081+otamam818@users.noreply.github.com> Date: Thu, 7 Mar 2024 04:30:13 +1100 Subject: [PATCH] fix: fix `plugins/fs` infinite loop on autoregen (#1029) * Created safety check for redundant autogenerations * Accounted for empty file case, added .changes file * Update plugins/fs/build.rs --- .changes/file-autogen-fix.md | 6 ++++++ plugins/fs/build.rs | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changes/file-autogen-fix.md diff --git a/.changes/file-autogen-fix.md b/.changes/file-autogen-fix.md new file mode 100644 index 000000000..0a8705094 --- /dev/null +++ b/.changes/file-autogen-fix.md @@ -0,0 +1,6 @@ +--- +"fs": patch +"fs-js": patch +--- + +Fix infinite loop on cargo build operations \ No newline at end of file diff --git a/plugins/fs/build.rs b/plugins/fs/build.rs index 1901f3a48..dcfefd294 100644 --- a/plugins/fs/build.rs +++ b/plugins/fs/build.rs @@ -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)