@@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
44use tauri:: { AppHandle , State } ;
55
66use crate :: core:: process_manager:: PROCESS_MANAGER ;
7- use crate :: object:: structs:: { AppState , FileItem } ;
7+ use crate :: object:: structs:: AppState ;
88use crate :: utils:: github_proxy:: apply_github_proxy;
99use 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]
14491pub async fn get_available_versions (
14592 tool : String ,
0 commit comments