mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-26 21:41:48 +02:00
chore: edition 2024
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use serde::de::DeserializeOwned;
|
||||
use tauri::{plugin::PluginApi, AppHandle, Runtime};
|
||||
use tauri::{AppHandle, Runtime, plugin::PluginApi};
|
||||
|
||||
use crate::{models::*, FilePath, OpenOptions};
|
||||
use crate::{FilePath, OpenOptions, models::*};
|
||||
|
||||
const PLUGIN_IDENTIFIER: &str = "com.plugin.fs";
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
use serde::{Deserialize, Serialize, Serializer};
|
||||
use serde_repr::{Deserialize_repr, Serialize_repr};
|
||||
use tauri::{
|
||||
Manager, Resource, ResourceId, Runtime, Webview,
|
||||
ipc::{CommandScope, GlobalScope},
|
||||
path::BaseDirectory,
|
||||
utils::config::FsScope,
|
||||
Manager, Resource, ResourceId, Runtime, Webview,
|
||||
};
|
||||
|
||||
use std::{
|
||||
@@ -23,7 +23,7 @@ use std::{
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use crate::{scope::Entry, Error, SafeFilePath};
|
||||
use crate::{Error, SafeFilePath, scope::Entry};
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum CommandError {
|
||||
@@ -175,7 +175,9 @@ impl<R: Runtime> Drop for FileHandle<R> {
|
||||
.stop_accessing_security_scoped_resource(FilePath::Url(url.clone()));
|
||||
security_scoped_resources.remove(url.as_str());
|
||||
} else {
|
||||
log::debug!("Not cleaning up security-scoped resource for URL: {url} on drop (manually tracked via start_accessing_security_scoped_resource)");
|
||||
log::debug!(
|
||||
"Not cleaning up security-scoped resource for URL: {url} on drop (manually tracked via start_accessing_security_scoped_resource)"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,7 +253,9 @@ impl<R: Runtime> Drop for PathHandle<R> {
|
||||
.stop_accessing_security_scoped_resource(FilePath::Url(url.clone()));
|
||||
security_scoped_resources.remove(url.as_str());
|
||||
} else {
|
||||
log::debug!("Not cleaning up security-scoped resource for URL: {url} on drop (manually tracked via start_accessing_security_scoped_resource)");
|
||||
log::debug!(
|
||||
"Not cleaning up security-scoped resource for URL: {url} on drop (manually tracked via start_accessing_security_scoped_resource)"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1530,7 +1534,10 @@ pub fn resolve_path<R: Runtime>(
|
||||
unsafe {
|
||||
let success = ns_url.startAccessingSecurityScopedResource();
|
||||
if success {
|
||||
log::debug!("Started accessing security-scoped resource for URL: {} (via resolve_path)", url.as_str());
|
||||
log::debug!(
|
||||
"Started accessing security-scoped resource for URL: {} (via resolve_path)",
|
||||
url.as_str()
|
||||
);
|
||||
// Track it so we know to clean it up
|
||||
security_scoped_resources.track_manually(url.as_str().to_string());
|
||||
} else {
|
||||
@@ -1541,10 +1548,16 @@ pub fn resolve_path<R: Runtime>(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log::debug!("Failed to create NSURL from URL: {}, ignoring security-scoped resource access request", url.as_str());
|
||||
log::debug!(
|
||||
"Failed to create NSURL from URL: {}, ignoring security-scoped resource access request",
|
||||
url.as_str()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
log::debug!("Security-scoped resource already active for URL: {} (started via start_accessing_security_scoped_resource), skipping", url.as_str());
|
||||
log::debug!(
|
||||
"Security-scoped resource already active for URL: {} (started via start_accessing_security_scoped_resource), skipping",
|
||||
url.as_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,11 +190,10 @@ impl<'de> serde::Deserialize<'de> for SafeFilePath {
|
||||
impl FromStr for FilePath {
|
||||
type Err = Infallible;
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
if let Ok(url) = url::Url::from_str(s) {
|
||||
if url.scheme().len() != 1 {
|
||||
if let Ok(url) = url::Url::from_str(s)
|
||||
&& url.scheme().len() != 1 {
|
||||
return Ok(Self::Url(url));
|
||||
}
|
||||
}
|
||||
Ok(Self::Path(PathBuf::from(s)))
|
||||
}
|
||||
}
|
||||
@@ -202,11 +201,10 @@ impl FromStr for FilePath {
|
||||
impl FromStr for SafeFilePath {
|
||||
type Err = Error;
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
if let Ok(url) = url::Url::from_str(s) {
|
||||
if url.scheme().len() != 1 {
|
||||
if let Ok(url) = url::Url::from_str(s)
|
||||
&& url.scheme().len() != 1 {
|
||||
return Ok(Self::Url(url));
|
||||
}
|
||||
}
|
||||
|
||||
SafePathBuf::new(s.into())
|
||||
.map(SafeFilePath::Path)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use serde::de::DeserializeOwned;
|
||||
use tauri::{plugin::PluginApi, AppHandle, Runtime};
|
||||
use tauri::{AppHandle, Runtime, plugin::PluginApi};
|
||||
|
||||
use crate::{FilePath, OpenOptions};
|
||||
|
||||
@@ -69,7 +69,10 @@ impl<R: Runtime> Fs<R> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log::debug!("Failed to create NSURL from URL: {}, ignoring security-scoped resource access request", url_string);
|
||||
log::debug!(
|
||||
"Failed to create NSURL from URL: {}, ignoring security-scoped resource access request",
|
||||
url_string
|
||||
);
|
||||
}
|
||||
|
||||
// Convert URL to path and open the file
|
||||
|
||||
@@ -22,10 +22,10 @@ use std::sync::Mutex;
|
||||
|
||||
use serde::Deserialize;
|
||||
use tauri::{
|
||||
AppHandle, DragDropEvent, Manager, RunEvent, Runtime, WindowEvent,
|
||||
ipc::ScopeObject,
|
||||
plugin::{Builder as PluginBuilder, TauriPlugin},
|
||||
utils::{acl::Value, config::FsScope},
|
||||
AppHandle, DragDropEvent, Manager, RunEvent, Runtime, WindowEvent,
|
||||
};
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher};
|
||||
use notify_debouncer_full::{new_debouncer, DebouncedEvent, Debouncer, RecommendedCache};
|
||||
use notify_debouncer_full::{DebouncedEvent, Debouncer, RecommendedCache, new_debouncer};
|
||||
use serde::Deserialize;
|
||||
use tauri::{
|
||||
Manager, Resource, ResourceId, Runtime, Webview,
|
||||
ipc::{Channel, CommandScope, GlobalScope},
|
||||
path::BaseDirectory,
|
||||
Manager, Resource, ResourceId, Runtime, Webview,
|
||||
};
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::{
|
||||
commands::{resolve_path, CommandResult},
|
||||
scope::Entry,
|
||||
SafeFilePath,
|
||||
commands::{CommandResult, resolve_path},
|
||||
scope::Entry,
|
||||
};
|
||||
|
||||
#[allow(unused)]
|
||||
|
||||
Reference in New Issue
Block a user