From fcbd18c4b7d90388a9a2b9e28555d2526727958c Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 25 Feb 2026 15:24:18 +0800 Subject: Replace string_proc with just_fmt as external dependency --- legacy_data/src/data/local.rs | 7 ++++-- legacy_data/src/data/local/cached_sheet.rs | 12 ++++++++--- legacy_data/src/data/local/local_files.rs | 4 ++-- legacy_data/src/data/local/local_sheet.rs | 27 +++++++++++++++++------- legacy_data/src/data/local/workspace_analyzer.rs | 4 ++-- legacy_data/src/data/local/workspace_config.rs | 2 +- legacy_data/src/data/member.rs | 2 +- legacy_data/src/data/vault/mapping_share.rs | 4 ++-- legacy_data/src/data/vault/sheet_manage.rs | 2 +- legacy_data/src/data/vault/virtual_file.rs | 2 +- 10 files changed, 43 insertions(+), 23 deletions(-) (limited to 'legacy_data/src/data') diff --git a/legacy_data/src/data/local.rs b/legacy_data/src/data/local.rs index d4115c6..8423168 100644 --- a/legacy_data/src/data/local.rs +++ b/legacy_data/src/data/local.rs @@ -1,12 +1,13 @@ use std::{ collections::HashMap, env::current_dir, + io::ErrorKind, path::{Path, PathBuf}, sync::Arc, }; use cfg_file::config::ConfigFile; -use string_proc::format_path::format_path; +use just_fmt::fmt_path::fmt_path; use tokio::{fs, sync::Mutex}; use vcs_docs::docs::READMES_LOCAL_WORKSPACE_TODOLIST; @@ -176,7 +177,9 @@ impl LocalWorkspace { && let Some(extension) = path.extension() && extension == suffix.trim_start_matches('.') { - let formatted_path = format_path(path)?; + let formatted_path = fmt_path(path).map_err(|e| { + std::io::Error::new(ErrorKind::InvalidInput, e.to_string()) + })?; paths.push(formatted_path); } } diff --git a/legacy_data/src/data/local/cached_sheet.rs b/legacy_data/src/data/local/cached_sheet.rs index 46b390f..e67861b 100644 --- a/legacy_data/src/data/local/cached_sheet.rs +++ b/legacy_data/src/data/local/cached_sheet.rs @@ -1,7 +1,10 @@ -use std::{io::Error, path::PathBuf}; +use std::{ + io::{Error, ErrorKind}, + path::PathBuf, +}; use cfg_file::config::ConfigFile; -use string_proc::{format_path::format_path, snake_case}; +use just_fmt::{fmt_path::fmt_path, snake_case}; use tokio::fs; use crate::{ @@ -85,7 +88,10 @@ impl CachedSheet { && let Some(file_name) = path.file_name().and_then(|n| n.to_str()) && file_name.ends_with(CLIENT_SUFFIX_CACHED_SHEET_FILE) { - sheet_paths.push(format_path(workspace_path.join(path))?); + sheet_paths + .push(fmt_path(workspace_path.join(path)).map_err(|e| { + std::io::Error::new(ErrorKind::InvalidInput, e.to_string()) + })?); } } diff --git a/legacy_data/src/data/local/local_files.rs b/legacy_data/src/data/local/local_files.rs index 9cc244f..2f02b32 100644 --- a/legacy_data/src/data/local/local_files.rs +++ b/legacy_data/src/data/local/local_files.rs @@ -1,6 +1,6 @@ use std::path::{Path, PathBuf}; -use string_proc::format_path::format_path; +use just_fmt::fmt_path::fmt_path; use tokio::fs; use crate::constants::CLIENT_FOLDER_WORKSPACE_ROOT_NAME; @@ -59,7 +59,7 @@ async fn format_input_paths( continue; } - match format_path(path) { + match fmt_path(path) { Ok(path) => real_paths.push(path), Err(e) => { return Err(std::io::Error::new( diff --git a/legacy_data/src/data/local/local_sheet.rs b/legacy_data/src/data/local/local_sheet.rs index b9c29f5..eee0866 100644 --- a/legacy_data/src/data/local/local_sheet.rs +++ b/legacy_data/src/data/local/local_sheet.rs @@ -1,8 +1,13 @@ -use std::{collections::HashMap, io::Error, path::PathBuf, time::SystemTime}; +use std::{ + collections::HashMap, + io::{Error, ErrorKind}, + path::PathBuf, + time::SystemTime, +}; use ::serde::{Deserialize, Serialize}; use cfg_file::{ConfigFile, config::ConfigFile}; -use string_proc::format_path::format_path; +use just_fmt::fmt_path::fmt_path; use crate::{ constants::CLIENT_FILE_LOCAL_SHEET_NOSET, @@ -278,7 +283,8 @@ impl LocalSheetData { path: &LocalFilePathBuf, mapping: LocalMappingMetadata, ) -> Result<(), std::io::Error> { - let path = format_path(path)?; + let path = fmt_path(path) + .map_err(|e| std::io::Error::new(ErrorKind::InvalidInput, e.to_string()))?; if self.mapping.contains_key(&path) || self.vfs.contains_key(&mapping.mapping_vfid) { return Err(Error::new( std::io::ErrorKind::AlreadyExists, @@ -297,8 +303,10 @@ impl LocalSheetData { from: &LocalFilePathBuf, to: &LocalFilePathBuf, ) -> Result<(), std::io::Error> { - let from = format_path(from)?; - let to = format_path(to)?; + let from = fmt_path(from) + .map_err(|e| std::io::Error::new(ErrorKind::InvalidInput, e.to_string()))?; + let to = fmt_path(to) + .map_err(|e| std::io::Error::new(ErrorKind::InvalidInput, e.to_string()))?; if self.mapping.contains_key(&to) { return Err(Error::new( std::io::ErrorKind::AlreadyExists, @@ -325,7 +333,8 @@ impl LocalSheetData { &mut self, path: &LocalFilePathBuf, ) -> Result { - let path = format_path(path)?; + let path = fmt_path(path) + .map_err(|e| std::io::Error::new(ErrorKind::InvalidInput, e.to_string()))?; match self.mapping.remove(&path) { Some(mapping) => { self.vfs.remove(&mapping.mapping_vfid); @@ -343,7 +352,8 @@ impl LocalSheetData { &self, path: &LocalFilePathBuf, ) -> Result<&LocalMappingMetadata, std::io::Error> { - let path = format_path(path)?; + let path = fmt_path(path) + .map_err(|e| std::io::Error::new(ErrorKind::InvalidInput, e.to_string()))?; let Some(data) = self.mapping.get(&path) else { return Err(Error::new( std::io::ErrorKind::NotFound, @@ -358,7 +368,8 @@ impl LocalSheetData { &mut self, path: &LocalFilePathBuf, ) -> Result<&mut LocalMappingMetadata, std::io::Error> { - let path = format_path(path)?; + let path = fmt_path(path) + .map_err(|e| std::io::Error::new(ErrorKind::InvalidInput, e.to_string()))?; let Some(data) = self.mapping.get_mut(&path) else { return Err(Error::new( std::io::ErrorKind::NotFound, diff --git a/legacy_data/src/data/local/workspace_analyzer.rs b/legacy_data/src/data/local/workspace_analyzer.rs index 5d73e03..82cd4e0 100644 --- a/legacy_data/src/data/local/workspace_analyzer.rs +++ b/legacy_data/src/data/local/workspace_analyzer.rs @@ -4,9 +4,9 @@ use std::{ path::PathBuf, }; +use just_fmt::fmt_path::fmt_path; use serde::Serialize; use sha1_hash::calc_sha1_multi; -use string_proc::format_path::format_path; use walkdir::WalkDir; use crate::data::{ @@ -116,7 +116,7 @@ impl<'a> AnalyzeResult<'a> { if entry.file_type().is_file() && let Ok(relative_path) = entry.path().strip_prefix(local_path) { - let format = format_path(relative_path.to_path_buf()); + let format = fmt_path(relative_path.to_path_buf()); let Ok(format) = format else { continue; }; diff --git a/legacy_data/src/data/local/workspace_config.rs b/legacy_data/src/data/local/workspace_config.rs index f97d049..fc63e9c 100644 --- a/legacy_data/src/data/local/workspace_config.rs +++ b/legacy_data/src/data/local/workspace_config.rs @@ -1,11 +1,11 @@ use cfg_file::ConfigFile; use cfg_file::config::ConfigFile; +use just_fmt::snake_case; use serde::{Deserialize, Serialize}; use std::io::Error; use std::net::SocketAddr; use std::path::Path; use std::path::PathBuf; -use string_proc::snake_case; use crate::constants::CLIENT_FILE_WORKSPACE; use crate::constants::CLIENT_FOLDER_WORKSPACE_ROOT_NAME; diff --git a/legacy_data/src/data/member.rs b/legacy_data/src/data/member.rs index 7e99488..bcfa9bf 100644 --- a/legacy_data/src/data/member.rs +++ b/legacy_data/src/data/member.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; use cfg_file::ConfigFile; +use just_fmt::snake_case; use serde::{Deserialize, Serialize}; -use string_proc::snake_case; pub type MemberId = String; diff --git a/legacy_data/src/data/vault/mapping_share.rs b/legacy_data/src/data/vault/mapping_share.rs index 5d27859..59cd6ba 100644 --- a/legacy_data/src/data/vault/mapping_share.rs +++ b/legacy_data/src/data/vault/mapping_share.rs @@ -1,9 +1,9 @@ use std::{collections::HashMap, io::Error, path::PathBuf}; use cfg_file::{ConfigFile, config::ConfigFile}; +use just_fmt::{fmt_path::fmt_path_str, snake_case}; use rand::{Rng, rng}; use serde::{Deserialize, Serialize}; -use string_proc::{format_path, snake_case}; use tokio::fs; use crate::{ @@ -89,7 +89,7 @@ impl Vault { .replace(KEY_SHARE_ID, &share_id); // Use format_path to normalize the path - match format_path::format_path_str(&path_str) { + match fmt_path_str(&path_str) { Ok(normalized_path) => self.vault_path().join(normalized_path), Err(_) => { // Fallback to original behavior if formatting fails diff --git a/legacy_data/src/data/vault/sheet_manage.rs b/legacy_data/src/data/vault/sheet_manage.rs index c22c849..70fef88 100644 --- a/legacy_data/src/data/vault/sheet_manage.rs +++ b/legacy_data/src/data/vault/sheet_manage.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, io::Error}; use cfg_file::config::ConfigFile; -use string_proc::snake_case; +use just_fmt::snake_case; use tokio::fs; use crate::{ diff --git a/legacy_data/src/data/vault/virtual_file.rs b/legacy_data/src/data/vault/virtual_file.rs index 28e9172..06ec3f4 100644 --- a/legacy_data/src/data/vault/virtual_file.rs +++ b/legacy_data/src/data/vault/virtual_file.rs @@ -5,8 +5,8 @@ use std::{ }; use cfg_file::{ConfigFile, config::ConfigFile}; +use just_fmt::{dot_case, snake_case}; use serde::{Deserialize, Serialize}; -use string_proc::{dot_case, snake_case}; use tcp_connection::instance::ConnectionInstance; use tokio::fs; use uuid::Uuid; -- cgit