fix(rust): spawn_blocking 改走 tauri::async_runtime(工程无 tokio 依赖,Windows 构建 E0433)
6 处 tokio::task::spawn_blocking(Git 同步 4 处 + docs/29 资源 命令 2 处)全部换成工程既有写法 tauri::async_runtime::spawn_blocking; 全量核对源码外部 crate 前缀与 Cargo.toml 依赖一致。docs/29 补勘误。
This commit is contained in:
@@ -190,3 +190,11 @@ src-tauri/src/ 全部(1289 行)。先说结论:发现 **1 个高危数据
|
|||||||
- H1 的守卫交错无法在 jsdom 自动化复现(见上),真机侧可用
|
- H1 的守卫交错无法在 jsdom 自动化复现(见上),真机侧可用
|
||||||
「打开 >60K 文档后立刻连开多个标签挤掉其窗格,再回看该文档
|
「打开 >60K 文档后立刻连开多个标签挤掉其窗格,再回看该文档
|
||||||
是否完整」一验。
|
是否完整」一验。
|
||||||
|
- **勘误(2026-11-14 晚,Windows 构建回报)**:本轮 M1 与 docs/27
|
||||||
|
的 Git 命令共 6 处用了 `tokio::task::spawn_blocking`,但工程并
|
||||||
|
没有 tokio 直接依赖(Cargo.toml 只有 tauri 等 7 个),Windows
|
||||||
|
构建报 E0433。已全部改为工程既有写法的
|
||||||
|
`tauri::async_runtime::spawn_blocking`(read/write 命令一直在
|
||||||
|
用),并全量核对源码中所有外部 crate 前缀与 Cargo.toml 依赖
|
||||||
|
一致、无其他幻影 crate。教训:写 Rust 时新引入的 crate 路径
|
||||||
|
必须先对 Cargo.toml 存量,沙箱无法完整编译时尤其如此。
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ fn write_new_file(dir: &Path, file_name: &str, data: &[u8]) -> Result<PathBuf, S
|
|||||||
/// 大文件会冻 UI 线程且内存整载(docs/29)。
|
/// 大文件会冻 UI 线程且内存整载(docs/29)。
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn copy_to_assets(source: String, doc_path: String) -> Result<String, String> {
|
pub async fn copy_to_assets(source: String, doc_path: String) -> Result<String, String> {
|
||||||
tokio::task::spawn_blocking(move || {
|
tauri::async_runtime::spawn_blocking(move || {
|
||||||
let src = PathBuf::from(&source);
|
let src = PathBuf::from(&source);
|
||||||
let name = sanitize_file_name(
|
let name = sanitize_file_name(
|
||||||
&src.file_name()
|
&src.file_name()
|
||||||
@@ -287,7 +287,7 @@ pub async fn save_bytes_to_assets(
|
|||||||
file_name: String,
|
file_name: String,
|
||||||
base64: String,
|
base64: String,
|
||||||
) -> Result<String, String> {
|
) -> Result<String, String> {
|
||||||
tokio::task::spawn_blocking(move || {
|
tauri::async_runtime::spawn_blocking(move || {
|
||||||
let name = sanitize_file_name(&file_name);
|
let name = sanitize_file_name(&file_name);
|
||||||
let bytes = base64_decode(&base64)?;
|
let bytes = base64_decode(&base64)?;
|
||||||
if bytes.len() as u64 > MAX_ASSET_BYTES {
|
if bytes.len() as u64 > MAX_ASSET_BYTES {
|
||||||
@@ -784,7 +784,7 @@ fn git_status_inner(root: &str) -> GitStatusInfo {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn git_status(root: String) -> GitStatusInfo {
|
pub async fn git_status(root: String) -> GitStatusInfo {
|
||||||
tokio::task::spawn_blocking(move || git_status_inner(&root))
|
tauri::async_runtime::spawn_blocking(move || git_status_inner(&root))
|
||||||
.await
|
.await
|
||||||
.unwrap_or(GitStatusInfo {
|
.unwrap_or(GitStatusInfo {
|
||||||
is_repo: false,
|
is_repo: false,
|
||||||
@@ -799,7 +799,7 @@ pub async fn git_status(root: String) -> GitStatusInfo {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn git_init_repo(root: String, remote_url: String, branch: String) -> Result<GitStatusInfo, String> {
|
pub async fn git_init_repo(root: String, remote_url: String, branch: String) -> Result<GitStatusInfo, String> {
|
||||||
tokio::task::spawn_blocking(move || {
|
tauri::async_runtime::spawn_blocking(move || {
|
||||||
let dir = Path::new(&root);
|
let dir = Path::new(&root);
|
||||||
let b = validate_branch(&branch)?;
|
let b = validate_branch(&branch)?;
|
||||||
let url = validate_remote_url(&remote_url)?;
|
let url = validate_remote_url(&remote_url)?;
|
||||||
@@ -833,7 +833,7 @@ pub async fn git_init_repo(root: String, remote_url: String, branch: String) ->
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn git_set_remote(root: String, remote_url: String) -> Result<GitStatusInfo, String> {
|
pub async fn git_set_remote(root: String, remote_url: String) -> Result<GitStatusInfo, String> {
|
||||||
tokio::task::spawn_blocking(move || {
|
tauri::async_runtime::spawn_blocking(move || {
|
||||||
let dir = Path::new(&root);
|
let dir = Path::new(&root);
|
||||||
let url_owned = validate_remote_url(&remote_url)?;
|
let url_owned = validate_remote_url(&remote_url)?;
|
||||||
let url = url_owned.as_str();
|
let url = url_owned.as_str();
|
||||||
@@ -855,7 +855,7 @@ pub async fn git_set_remote(root: String, remote_url: String) -> Result<GitStatu
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn git_sync_now(root: String, message: String) -> Result<GitSyncOutcome, String> {
|
pub async fn git_sync_now(root: String, message: String) -> Result<GitSyncOutcome, String> {
|
||||||
tokio::task::spawn_blocking(move || {
|
tauri::async_runtime::spawn_blocking(move || {
|
||||||
let dir = Path::new(&root);
|
let dir = Path::new(&root);
|
||||||
let st = git_status_inner(&root);
|
let st = git_status_inner(&root);
|
||||||
if !st.is_repo {
|
if !st.is_repo {
|
||||||
|
|||||||
Reference in New Issue
Block a user