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]]
name = "tauri"
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 = [
"anyhow",
"bytes 1.4.0",
@ -4451,7 +4452,8 @@ dependencies = [
[[package]]
name = "tauri-build"
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 = [
"anyhow",
"cargo_toml",
@ -4470,7 +4472,8 @@ dependencies = [
[[package]]
name = "tauri-codegen"
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 = [
"base64 0.21.0",
"brotli",
@ -4495,7 +4498,8 @@ dependencies = [
[[package]]
name = "tauri-macros"
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 = [
"heck",
"proc-macro2",
@ -4548,18 +4552,6 @@ dependencies = [
"thiserror",
]
[[package]]
name = "tauri-plugin-fs"
version = "0.1.0"
dependencies = [
"anyhow",
"log",
"serde",
"serde_json",
"tauri",
"thiserror",
]
[[package]]
name = "tauri-plugin-fs-watch"
version = "0.1.0"
@ -4731,7 +4723,8 @@ dependencies = [
[[package]]
name = "tauri-runtime"
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 = [
"gtk",
"http",
@ -4752,7 +4745,8 @@ dependencies = [
[[package]]
name = "tauri-runtime-wry"
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 = [
"cocoa",
"gtk",
@ -4772,7 +4766,8 @@ dependencies = [
[[package]]
name = "tauri-utils"
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 = [
"brotli",
"ctor",

@ -1,12 +1,13 @@
[workspace]
members = ["plugins/*"]
exclude = ["plugins/fs"]
resolver = "2"
[workspace.dependencies]
serde = { version = "1", features = ["derive"] }
log = "0.4"
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "refactor/move-fs" }
tauri-build = { git = "https://github.com/tauri-apps/tauri", branch = "refactor/move-fs" }
tauri = "2.0.0-alpha.8"
tauri-build = "2.0.0-alpha.4"
serde_json = "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"
version = "0.1.0"
description = "Access the file system."
authors.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true
edition = "2021"
#authors.workspace = true
#license.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
[dependencies]
serde.workspace = true
serde_json.workspace = true
tauri.workspace = true
log.workspace = true
thiserror.workspace = true
#serde.workspace = true
#serde_json.workspace = true
#tauri.workspace = true
#log.workspace = true
#thiserror.workspace = true
serde = "1"
thiserror = "1"
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next" }
anyhow = "1"

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

Loading…
Cancel
Save