feat(core): expose scope::fs::Scope::new (#8432)

This commit is contained in:
Lucas Fernandes Nogueira 2023-12-18 21:29:12 -03:00 committed by GitHub
parent 11a1529d6a
commit b59f2f54e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": patch:feat
---
Expose `scope::fs::Scope::new`.

View File

@ -1568,7 +1568,7 @@ impl<R: Runtime> Builder<R> {
app.manage(Scopes { app.manage(Scopes {
ipc: scope::ipc::Scope::new(app.config()), ipc: scope::ipc::Scope::new(app.config()),
#[cfg(feature = "protocol-asset")] #[cfg(feature = "protocol-asset")]
asset_protocol: scope::fs::Scope::for_fs_api( asset_protocol: scope::fs::Scope::new(
&app, &app,
&app.config().tauri.security.asset_protocol.scope, &app.config().tauri.security.asset_protocol.scope,
)?, )?,

View File

@ -91,11 +91,10 @@ fn push_pattern<P: AsRef<Path>, F: Fn(&str) -> Result<Pattern, glob::PatternErro
} }
impl Scope { impl Scope {
/// Creates a new scope from a `FsAllowlistScope` configuration. /// Creates a new scope from a [`FsScope`] configuration.
#[allow(unused)] pub fn new<R: crate::Runtime, M: crate::Manager<R>>(
pub(crate) fn for_fs_api<R: crate::Runtime, M: crate::Manager<R>>(
manager: &M, manager: &M,
scope: &tauri_utils::config::FsScope, scope: &FsScope,
) -> crate::Result<Self> { ) -> crate::Result<Self> {
let mut allowed_patterns = HashSet::new(); let mut allowed_patterns = HashSet::new();
for path in scope.allowed_paths() { for path in scope.allowed_paths() {