feat: use tauri from git only on fs plugin

pull/308/head
Lucas Nogueira 2 years ago
parent d823268b03
commit 09b106f42e
No known key found for this signature in database
GPG Key ID: FFEA6C72E73482F1

33
Cargo.lock generated

@ -4400,7 +4400,8 @@ dependencies = [
[[package]] [[package]]
name = "tauri" name = "tauri"
version = "2.0.0-alpha.8" version = "2.0.0-alpha.8"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/move-fs#5659ca10eb68b8c0a2439ff6c10585b4f38d8cc2" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f25eefe4ca0a396a73fd0309f778eeb22a19953a3169bf316b893abadc2118fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes 1.4.0", "bytes 1.4.0",
@ -4451,7 +4452,8 @@ dependencies = [
[[package]] [[package]]
name = "tauri-build" name = "tauri-build"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/move-fs#5659ca10eb68b8c0a2439ff6c10585b4f38d8cc2" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c492211c72b95f8866e5c1fbc0a915080a5ebb9f03f9b250a1c936534b680a76"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cargo_toml", "cargo_toml",
@ -4470,7 +4472,8 @@ dependencies = [
[[package]] [[package]]
name = "tauri-codegen" name = "tauri-codegen"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/move-fs#5659ca10eb68b8c0a2439ff6c10585b4f38d8cc2" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "818c570932ebc2ff6d498be89d93494b89ff142131937a7e56d7cfb9c8ef0ad0"
dependencies = [ dependencies = [
"base64 0.21.0", "base64 0.21.0",
"brotli", "brotli",
@ -4495,7 +4498,8 @@ dependencies = [
[[package]] [[package]]
name = "tauri-macros" name = "tauri-macros"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/move-fs#5659ca10eb68b8c0a2439ff6c10585b4f38d8cc2" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3b596485d89003d2d7869469b2830e9a846de9ac2eecd69bc7c24890234aefc"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
@ -4548,18 +4552,6 @@ dependencies = [
"thiserror", "thiserror",
] ]
[[package]]
name = "tauri-plugin-fs"
version = "0.1.0"
dependencies = [
"anyhow",
"log",
"serde",
"serde_json",
"tauri",
"thiserror",
]
[[package]] [[package]]
name = "tauri-plugin-fs-watch" name = "tauri-plugin-fs-watch"
version = "0.1.0" version = "0.1.0"
@ -4731,7 +4723,8 @@ dependencies = [
[[package]] [[package]]
name = "tauri-runtime" name = "tauri-runtime"
version = "0.13.0-alpha.4" version = "0.13.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/move-fs#5659ca10eb68b8c0a2439ff6c10585b4f38d8cc2" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "404367cd32a5a8d33368448aab7da54bb2187b6a632526f1019de3fd13591cc2"
dependencies = [ dependencies = [
"gtk", "gtk",
"http", "http",
@ -4752,7 +4745,8 @@ dependencies = [
[[package]] [[package]]
name = "tauri-runtime-wry" name = "tauri-runtime-wry"
version = "0.13.0-alpha.4" version = "0.13.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/move-fs#5659ca10eb68b8c0a2439ff6c10585b4f38d8cc2" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "203764d673b440877dea87b972772be4091ee0ab25141748008646ca774a20dc"
dependencies = [ dependencies = [
"cocoa", "cocoa",
"gtk", "gtk",
@ -4772,7 +4766,8 @@ dependencies = [
[[package]] [[package]]
name = "tauri-utils" name = "tauri-utils"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/move-fs#5659ca10eb68b8c0a2439ff6c10585b4f38d8cc2" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49fa79bc56f04ece491268a64273de945f65627bcda30d9e8ecc8708b89bca26"
dependencies = [ dependencies = [
"brotli", "brotli",
"ctor", "ctor",

@ -1,12 +1,13 @@
[workspace] [workspace]
members = ["plugins/*"] members = ["plugins/*"]
exclude = ["plugins/fs"]
resolver = "2" resolver = "2"
[workspace.dependencies] [workspace.dependencies]
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
log = "0.4" log = "0.4"
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "refactor/move-fs" } tauri = "2.0.0-alpha.8"
tauri-build = { git = "https://github.com/tauri-apps/tauri", branch = "refactor/move-fs" } tauri-build = "2.0.0-alpha.4"
serde_json = "1" serde_json = "1"
thiserror = "1" thiserror = "1"

3591
plugins/fs/Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -2,17 +2,21 @@
name = "tauri-plugin-fs" name = "tauri-plugin-fs"
version = "0.1.0" version = "0.1.0"
description = "Access the file system." description = "Access the file system."
authors.workspace = true edition = "2021"
license.workspace = true #authors.workspace = true
edition.workspace = true #license.workspace = true
rust-version.workspace = true #edition.workspace = true
#rust-version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
serde.workspace = true #serde.workspace = true
serde_json.workspace = true #serde_json.workspace = true
tauri.workspace = true #tauri.workspace = true
log.workspace = true #log.workspace = true
thiserror.workspace = true #thiserror.workspace = true
serde = "1"
thiserror = "1"
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next" }
anyhow = "1" anyhow = "1"

@ -60,7 +60,7 @@ fn resolve_path<R: Runtime>(
window: &Window<R>, window: &Window<R>,
path: SafePathBuf, path: SafePathBuf,
dir: Option<BaseDirectory>, dir: Option<BaseDirectory>,
) -> Result<SafePathBuf> { ) -> Result<PathBuf> {
let path = if let Some(dir) = dir { let path = if let Some(dir) = dir {
window window
.path() .path()
@ -70,10 +70,7 @@ fn resolve_path<R: Runtime>(
path.as_ref().to_path_buf() path.as_ref().to_path_buf()
}; };
if window.fs_scope().is_allowed(&path) { if window.fs_scope().is_allowed(&path) {
Ok( Ok(path)
// safety: the path is resolved by Tauri so it is safe
unsafe { SafePathBuf::new_unchecked(path) },
)
} else { } else {
Err(Error::PathForbidden(path)) Err(Error::PathForbidden(path))
} }
@ -206,15 +203,21 @@ pub fn copy_file<R: Runtime>(
destination: SafePathBuf, destination: SafePathBuf,
options: Option<FileOperationOptions>, options: Option<FileOperationOptions>,
) -> CommandResult<()> { ) -> CommandResult<()> {
let (src, dest) = match options.and_then(|o| o.dir) { match options.and_then(|o| o.dir) {
Some(dir) => ( Some(dir) => {
resolve_path(&window, source, Some(dir))?, let src = resolve_path(&window, source, Some(dir))?;
resolve_path(&window, destination, Some(dir))?, let dest = resolve_path(&window, destination, Some(dir))?;
), fs::copy(&src, &dest)
None => (source, destination), .with_context(|| format!("source: {}, dest: {}", src.display(), dest.display()))?
}
None => fs::copy(&source, &destination).with_context(|| {
format!(
"source: {}, dest: {}",
source.display(),
destination.display()
)
})?,
}; };
fs::copy(src.clone(), dest.clone())
.with_context(|| format!("source: {}, dest: {}", src.display(), dest.display()))?;
Ok(()) Ok(())
} }
@ -283,16 +286,17 @@ pub fn rename_file<R: Runtime>(
new_path: SafePathBuf, new_path: SafePathBuf,
options: Option<FileOperationOptions>, options: Option<FileOperationOptions>,
) -> CommandResult<()> { ) -> CommandResult<()> {
let (old, new) = match options.and_then(|o| o.dir) { match options.and_then(|o| o.dir) {
Some(dir) => ( Some(dir) => {
resolve_path(&window, old_path, Some(dir))?, let old = resolve_path(&window, old_path, Some(dir))?;
resolve_path(&window, new_path, Some(dir))?, let new = resolve_path(&window, new_path, Some(dir))?;
), fs::rename(&old, &new)
None => (old_path, new_path), .with_context(|| format!("old: {}, new: {}", old.display(), new.display()))?
}; }
fs::rename(&old, &new) None => fs::rename(&old_path, &new_path)
.with_context(|| format!("old: {}, new: {}", old.display(), new.display())) .with_context(|| format!("old: {}, new: {}", old_path.display(), new_path.display()))?,
.map_err(Into::into) }
Ok(())
} }
#[tauri::command] #[tauri::command]
@ -302,7 +306,7 @@ pub fn exists<R: Runtime>(
options: Option<FileOperationOptions>, options: Option<FileOperationOptions>,
) -> CommandResult<bool> { ) -> CommandResult<bool> {
let resolved_path = resolve_path(&window, path, options.and_then(|o| o.dir))?; let resolved_path = resolve_path(&window, path, options.and_then(|o| o.dir))?;
Ok(resolved_path.as_ref().exists()) Ok(resolved_path.exists())
} }
#[derive(Serialize)] #[derive(Serialize)]

Loading…
Cancel
Save