@@ -3,6 +3,31 @@ use std::{env, fs};
33
44pub static APP_ID : & str = "io.github.openlistteam.openlist.desktop" ;
55
6+ // Normalize path without Windows long path prefix (\\?\)
7+ // The \\?\ prefix breaks compatibility with some applications like SQLite
8+ fn normalize_path ( path : & PathBuf ) -> Result < PathBuf , String > {
9+ #[ cfg( target_os = "windows" ) ]
10+ {
11+ // On Windows, use canonicalize but strip the \\?\ prefix if present
12+ let canonical = path
13+ . canonicalize ( )
14+ . map_err ( |e| format ! ( "Failed to canonicalize path: {e}" ) ) ?;
15+
16+ let path_str = canonical. to_string_lossy ( ) ;
17+ if let Some ( stripped) = path_str. strip_prefix ( r"\\?\" ) {
18+ Ok ( PathBuf :: from ( stripped) )
19+ } else {
20+ Ok ( canonical)
21+ }
22+ }
23+
24+ #[ cfg( not( target_os = "windows" ) ) ]
25+ {
26+ path. canonicalize ( )
27+ . map_err ( |e| format ! ( "Failed to canonicalize path: {e}" ) )
28+ }
29+ }
30+
631fn get_app_dir ( ) -> Result < PathBuf , String > {
732 let app_dir = env:: current_exe ( )
833 . map_err ( |e| format ! ( "Failed to get current exe path: {e}" ) ) ?
@@ -46,9 +71,7 @@ fn get_user_data_dir() -> Result<PathBuf, String> {
4671
4772 fs:: create_dir_all ( & data_dir) . map_err ( |e| format ! ( "Failed to create data directory: {e}" ) ) ?;
4873
49- data_dir
50- . canonicalize ( )
51- . map_err ( |e| format ! ( "Failed to canonicalize data directory: {e}" ) )
74+ normalize_path ( & data_dir)
5275}
5376
5477fn get_user_logs_dir ( ) -> Result < PathBuf , String > {
@@ -69,9 +92,7 @@ fn get_user_logs_dir() -> Result<PathBuf, String> {
6992 } ;
7093
7194 fs:: create_dir_all ( & logs_dir) . map_err ( |e| format ! ( "Failed to create logs directory: {e}" ) ) ?;
72- logs_dir
73- . canonicalize ( )
74- . map_err ( |e| format ! ( "Failed to canonicalize logs directory: {e}" ) )
95+ normalize_path ( & logs_dir)
7596}
7697
7798fn get_binary_path ( binary : & str , service_name : & str ) -> Result < PathBuf , String > {
@@ -123,16 +144,14 @@ pub fn get_service_log_path() -> Result<PathBuf, String> {
123144 let home = env:: var ( "HOME" ) . map_err ( |_| "Failed to get HOME environment variable" ) ?;
124145 let logs = PathBuf :: from ( home)
125146 . join ( "Library" )
126- . join ( "Application Support" )
127- . join ( "io.github.openlistteam.openlist.service.bundle" )
128- . join ( "Contents" )
129- . join ( "MacOS" )
147+ . join ( "Logs" )
148+ . join ( "OpenList Desktop" )
130149 . join ( "openlist-desktop-service.log" ) ;
131150 Ok ( logs)
132151 }
133152
134153 #[ cfg( not( target_os = "macos" ) ) ]
135154 {
136- Ok ( get_user_data_dir ( ) ?. join ( "openlist-desktop-service.log" ) )
155+ Ok ( get_app_logs_dir ( ) ?. join ( "openlist-desktop-service.log" ) )
137156 }
138157}
0 commit comments