Skip to content

Commit 0f2789c

Browse files
authored
fix(build): do not rewrite unchanged schema (#8757)
* fix(build): do not rewrite unchanged schema * typo
1 parent b43c423 commit 0f2789c

4 files changed

Lines changed: 23 additions & 18 deletions

File tree

.changes/fix-rewrite-schema.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-build": patch:bug
3+
---
4+
5+
Do not rewrite capability JSON schema if it did not change.

core/tauri-build/src/acl.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
use std::{
66
collections::{BTreeMap, BTreeSet},
7-
fs::{copy, create_dir_all, read_to_string, File},
8-
io::{BufWriter, Write},
7+
fs::{copy, create_dir_all, read_to_string, write},
98
path::PathBuf,
109
};
1110

@@ -181,20 +180,21 @@ pub fn generate_schema(
181180
create_dir_all(&out_dir).context("unable to create schema output directory")?;
182181

183182
let schema_path = out_dir.join(format!("{target}-{CAPABILITIES_SCHEMA_FILE_NAME}"));
184-
let mut schema_file = BufWriter::new(File::create(&schema_path)?);
185-
write!(schema_file, "{schema_str}")?;
186-
187-
copy(
188-
schema_path,
189-
out_dir.join(format!(
190-
"{}-{CAPABILITIES_SCHEMA_FILE_NAME}",
191-
if target.is_desktop() {
192-
"desktop"
193-
} else {
194-
"mobile"
195-
}
196-
)),
197-
)?;
183+
if schema_str != read_to_string(&schema_path).unwrap_or_default() {
184+
write(&schema_path, "{schema_str}")?;
185+
186+
copy(
187+
schema_path,
188+
out_dir.join(format!(
189+
"{}-{CAPABILITIES_SCHEMA_FILE_NAME}",
190+
if target.is_desktop() {
191+
"desktop"
192+
} else {
193+
"mobile"
194+
}
195+
)),
196+
)?;
197+
}
198198

199199
Ok(())
200200
}

core/tauri-utils/src/acl/capability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub struct Capability {
5656
pub description: String,
5757
/// Execution context of the capability.
5858
///
59-
/// At runtime, Tauri filters the IPC command together with the context to determine wheter it is allowed or not and its scope.
59+
/// At runtime, Tauri filters the IPC command together with the context to determine whether it is allowed or not and its scope.
6060
#[serde(default)]
6161
pub context: CapabilityContext,
6262
/// List of windows that uses this capability. Can be a glob pattern.

examples/api/src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)