Skip to content

Commit 7126414

Browse files
committed
fix(tauri-plugin): do not modify src
Write temporary permission files to out_dir instead of current directory. The current directory is the source directory and it should not be modified by the build.
1 parent 766bccc commit 7126414

File tree

1 file changed

+13
-9
lines changed
  • crates/tauri-plugin/src/build

1 file changed

+13
-9
lines changed

crates/tauri-plugin/src/build/mod.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5-
use std::{
6-
collections::BTreeMap,
7-
path::{Path, PathBuf},
8-
};
5+
use std::{collections::BTreeMap, path::PathBuf};
96

107
use anyhow::Result;
118
use tauri_utils::acl::{self, Error};
@@ -107,7 +104,9 @@ impl<'a> Builder<'a> {
107104
// requirement: links MUST be set and MUST match the name
108105
let _links = std::env::var("CARGO_MANIFEST_LINKS").map_err(|_| Error::LinksMissing)?;
109106

110-
let autogenerated = Path::new("permissions").join(acl::build::AUTOGENERATED_FOLDER_NAME);
107+
let autogenerated = out_dir
108+
.join("permissions")
109+
.join(acl::build::AUTOGENERATED_FOLDER_NAME);
111110
std::fs::create_dir_all(&autogenerated).expect("unable to create permissions dir");
112111

113112
let commands_dir = autogenerated.join("commands");
@@ -116,18 +115,23 @@ impl<'a> Builder<'a> {
116115
}
117116

118117
println!("cargo:rerun-if-changed=permissions");
119-
let permissions =
120-
acl::build::define_permissions("./permissions/**/*.*", &name, &out_dir, |_| true)?;
118+
let permissions = acl::build::define_permissions(
119+
&format!("{}/permissions/**/*.*", out_dir.display()),
120+
&name,
121+
&out_dir,
122+
|_| true,
123+
)?;
121124

122125
if permissions.is_empty() {
123126
let _ = std::fs::remove_file(format!(
124-
"./permissions/{}/{}",
127+
"{}/permissions/{}/{}",
128+
out_dir.display(),
125129
acl::PERMISSION_SCHEMAS_FOLDER_NAME,
126130
acl::PERMISSION_SCHEMA_FILE_NAME
127131
));
128132
let _ = std::fs::remove_file(autogenerated.join(acl::build::PERMISSION_DOCS_FILE_NAME));
129133
} else {
130-
acl::schema::generate_permissions_schema(&permissions, "./permissions")?;
134+
acl::schema::generate_permissions_schema(&permissions, out_dir.join("permissions"))?;
131135
acl::build::generate_docs(
132136
&permissions,
133137
&autogenerated,

0 commit comments

Comments
 (0)