@@ -117,10 +117,10 @@ fn get_app_path(app: &App) -> String {
117117
118118/// Helper function to return `app`'s path.
119119///
120- /// * Windows/ macOS: extract `app_path`'s file name and remove the file extension
121- /// * Linux: return the name specified in `.desktop` file
120+ /// * macOS: extract `app_path`'s file name and remove the file extension
121+ /// * Windows/ Linux: return the name specified in `.desktop` file
122122async fn get_app_name ( app : & App ) -> String {
123- if cfg ! ( target_os = "linux" ) {
123+ if cfg ! ( any ( target_os = "linux" , target_os = "windows" ) ) {
124124 app. name . clone ( )
125125 } else {
126126 let app_path = get_app_path ( app) ;
@@ -1074,15 +1074,7 @@ pub async fn get_app_list<R: Runtime>(
10741074}
10751075
10761076#[ tauri:: command]
1077- pub async fn get_app_metadata < R : Runtime > (
1078- tauri_app_handle : AppHandle < R > ,
1079- app_path : String ,
1080- ) -> Result < AppMetadata , String > {
1081- let app =
1082- App :: from_path ( std:: path:: Path :: new ( & app_path) ) . expect ( "frontend sends an invalid app" ) ;
1083-
1084- let app_path = get_app_path ( & app) ;
1085- let app_name = get_app_name ( & app) . await ;
1077+ pub async fn get_app_metadata ( app_name : String , app_path : String ) -> Result < AppMetadata , String > {
10861078 let app_path_where = {
10871079 let app_path_borrowed_path = std:: path:: Path :: new ( app_path. as_str ( ) ) ;
10881080 let app_path_where = app_path_borrowed_path
@@ -1094,11 +1086,13 @@ pub async fn get_app_metadata<R: Runtime>(
10941086 . expect ( "it is guaranteed to be UTF-8 encoded" )
10951087 . to_string ( )
10961088 } ;
1097- let icon = get_app_icon_path ( & tauri_app_handle, & app) . await ?;
10981089
1099- let raw_app_metadata = metadata ( app_path. into ( ) , None ) . await ?;
1090+ let raw_app_metadata = metadata ( app_path. clone ( ) . into ( ) , None ) . await ?;
1091+
1092+ let last_opened = if cfg ! ( target_os = "macos" ) {
1093+ let app = App :: from_path ( std:: path:: Path :: new ( & app_path) )
1094+ . unwrap_or_else ( |e| panic ! ( "App::from_path({}) failed due to error '{}'" , app_path, e) ) ;
11001095
1101- let last_opened = if cfg ! ( any( target_os = "macos" , target_os = "windows" ) ) {
11021096 let app_exe_path = app
11031097 . app_path_exe
11041098 . as_ref ( )
@@ -1114,7 +1108,6 @@ pub async fn get_app_metadata<R: Runtime>(
11141108 name : app_name,
11151109 r#where : app_path_where,
11161110 size : raw_app_metadata. size ,
1117- icon,
11181111 created : raw_app_metadata. created_at ,
11191112 modified : raw_app_metadata. modified_at ,
11201113 last_opened,
0 commit comments