diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-02-25 15:24:18 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-02-25 15:24:18 +0800 |
| commit | fcbd18c4b7d90388a9a2b9e28555d2526727958c (patch) | |
| tree | 0de680895d6a162a99356d6e4d733942a339275e /legacy_data/src/data/local | |
| parent | 8b96e8171c4e9d6516fd63d37cbe613bd5927a04 (diff) | |
Replace string_proc with just_fmt as external dependency
Diffstat (limited to 'legacy_data/src/data/local')
| -rw-r--r-- | legacy_data/src/data/local/cached_sheet.rs | 12 | ||||
| -rw-r--r-- | legacy_data/src/data/local/local_files.rs | 4 | ||||
| -rw-r--r-- | legacy_data/src/data/local/local_sheet.rs | 27 | ||||
| -rw-r--r-- | legacy_data/src/data/local/workspace_analyzer.rs | 4 | ||||
| -rw-r--r-- | legacy_data/src/data/local/workspace_config.rs | 2 |
5 files changed, 33 insertions, 16 deletions
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<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()))?; 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; |
