Skip to content

Commit 83b96f6

Browse files
committed
refactor: remove unused function
1 parent 8ea65ff commit 83b96f6

3 files changed

Lines changed: 1 addition & 70 deletions

File tree

src-tauri/src/cmd/os_operate.rs

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
44
use tauri::{AppHandle, State};
55

66
use crate::core::process_manager::PROCESS_MANAGER;
7-
use crate::object::structs::{AppState, FileItem};
7+
use crate::object::structs::AppState;
88
use crate::utils::github_proxy::apply_github_proxy;
99
use crate::utils::path::{
1010
app_config_file_path, get_app_logs_dir, get_default_openlist_data_dir,
@@ -87,59 +87,6 @@ pub fn select_directory(title: String, app_handle: AppHandle) -> Result<Option<S
8787
Ok(dir_path.map(|path| path.to_string()))
8888
}
8989

90-
#[tauri::command]
91-
pub async fn list_files(
92-
path: String,
93-
_state: State<'_, AppState>,
94-
) -> Result<Vec<FileItem>, String> {
95-
let path_buf = PathBuf::from(&path);
96-
97-
if !path_buf.exists() {
98-
return Err("Path does not exist".to_string());
99-
}
100-
101-
let mut files = Vec::new();
102-
103-
if path_buf.is_dir() {
104-
let entries = fs::read_dir(&path_buf).map_err(|e| e.to_string())?;
105-
106-
for entry in entries {
107-
let entry = entry.map_err(|e| e.to_string())?;
108-
let metadata = entry.metadata().map_err(|e| e.to_string())?;
109-
let file_name = entry.file_name().to_string_lossy().to_string();
110-
let file_path = entry.path().to_string_lossy().to_string();
111-
112-
files.push(FileItem {
113-
name: file_name,
114-
path: file_path,
115-
is_dir: metadata.is_dir(),
116-
size: if metadata.is_file() {
117-
Some(metadata.len())
118-
} else {
119-
None
120-
},
121-
modified: metadata
122-
.modified()
123-
.ok()
124-
.and_then(|time| time.duration_since(std::time::UNIX_EPOCH).ok())
125-
.map(|duration| {
126-
chrono::DateTime::from_timestamp(duration.as_secs() as i64, 0)
127-
.unwrap_or_default()
128-
.to_rfc3339()
129-
}),
130-
});
131-
}
132-
}
133-
134-
files.sort_by(|a, b| match (a.is_dir, b.is_dir) {
135-
(true, false) => std::cmp::Ordering::Less,
136-
(false, true) => std::cmp::Ordering::Greater,
137-
_ => a.name.cmp(&b.name),
138-
});
139-
140-
Ok(files)
141-
}
142-
14390
#[tauri::command]
14491
pub async fn get_available_versions(
14592
tool: String,

src-tauri/src/object/structs.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ pub struct ServiceStatus {
1414
pub port: Option<u16>,
1515
}
1616

17-
#[derive(Debug, Serialize, Clone)]
18-
pub struct FileItem {
19-
pub name: String,
20-
pub path: String,
21-
pub is_dir: bool,
22-
pub size: Option<u64>,
23-
pub modified: Option<String>,
24-
}
25-
2617
#[derive(Debug, Serialize, Deserialize, Clone)]
2718
pub struct RcloneMountInfo {
2819
pub name: String,

src/stores/app.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -490,12 +490,6 @@ export const useAppStore = defineStore('app', () => {
490490
}
491491
}
492492

493-
const listFiles = (path: string) =>
494-
withLoading(async () => {
495-
files.value = await TauriAPI.files.list(path)
496-
currentPath.value = path
497-
}, 'Failed to list files')
498-
499493
async function openFile(path: string) {
500494
try {
501495
await TauriAPI.files.open(path)
@@ -738,7 +732,6 @@ export const useAppStore = defineStore('app', () => {
738732
refreshOpenListCoreStatus,
739733
loadLogs,
740734
clearLogs,
741-
listFiles,
742735
openFile,
743736
openFolder,
744737
openLogsDirectory,

0 commit comments

Comments
 (0)