Skip to content

Commit

Permalink
fix(build): do not rewrite unchanged schema (#8757)
Browse files Browse the repository at this point in the history
* fix(build): do not rewrite unchanged schema

* typo
  • Loading branch information
lucasfernog committed Feb 4, 2024
1 parent b43c423 commit 0f2789c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-rewrite-schema.md
@@ -0,0 +1,5 @@
---
"tauri-build": patch:bug
---

Do not rewrite capability JSON schema if it did not change.
32 changes: 16 additions & 16 deletions core/tauri-build/src/acl.rs
Expand Up @@ -4,8 +4,7 @@

use std::{
collections::{BTreeMap, BTreeSet},
fs::{copy, create_dir_all, read_to_string, File},
io::{BufWriter, Write},
fs::{copy, create_dir_all, read_to_string, write},
path::PathBuf,
};

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

let schema_path = out_dir.join(format!("{target}-{CAPABILITIES_SCHEMA_FILE_NAME}"));
let mut schema_file = BufWriter::new(File::create(&schema_path)?);
write!(schema_file, "{schema_str}")?;

copy(
schema_path,
out_dir.join(format!(
"{}-{CAPABILITIES_SCHEMA_FILE_NAME}",
if target.is_desktop() {
"desktop"
} else {
"mobile"
}
)),
)?;
if schema_str != read_to_string(&schema_path).unwrap_or_default() {
write(&schema_path, "{schema_str}")?;

copy(
schema_path,
out_dir.join(format!(
"{}-{CAPABILITIES_SCHEMA_FILE_NAME}",
if target.is_desktop() {
"desktop"
} else {
"mobile"
}
)),
)?;
}

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion core/tauri-utils/src/acl/capability.rs
Expand Up @@ -56,7 +56,7 @@ pub struct Capability {
pub description: String,
/// Execution context of the capability.
///
/// At runtime, Tauri filters the IPC command together with the context to determine wheter it is allowed or not and its scope.
/// At runtime, Tauri filters the IPC command together with the context to determine whether it is allowed or not and its scope.
#[serde(default)]
pub context: CapabilityContext,
/// List of windows that uses this capability. Can be a glob pattern.
Expand Down
2 changes: 1 addition & 1 deletion examples/api/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0f2789c

Please sign in to comment.