@@ -106,18 +106,28 @@ impl DatabaseHandle {
106106 }
107107}
108108
109- fn resolve_extension_path ( _app_handle : & AppHandle ) -> Option < PathBuf > {
110- let mut candidates: Vec < ( & str , PathBuf ) > = Vec :: new ( ) ;
111- match std:: env:: current_exe ( ) {
112- Ok ( current_exe) => {
113- if let Some ( exe_dir) = current_exe. parent ( ) {
114- candidates. push ( ( "sidecar" , exe_dir. join ( "absurd-extension" ) ) ) ;
115- candidates. push ( ( "sidecar bin" , exe_dir. join ( "bin" ) . join ( "absurd-extension" ) ) ) ;
116- } else {
117- log:: warn!( "Failed to resolve current executable directory" ) ;
109+ fn resolve_extension_path ( app_handle : & AppHandle ) -> Option < PathBuf > {
110+ let lib_name = extension_lib_name ( ) ;
111+ match app_handle. path ( ) . resource_dir ( ) {
112+ Ok ( resource_dir) => {
113+ let resource_path = resource_dir. join ( & lib_name) ;
114+ log:: debug!(
115+ "Checking resource SQLite extension at {}" ,
116+ resource_path. display( )
117+ ) ;
118+ if resource_path. exists ( ) {
119+ log:: info!(
120+ "Using resource SQLite extension at {}" ,
121+ resource_path. display( )
122+ ) ;
123+ return Some ( resource_path) ;
118124 }
125+ log:: warn!(
126+ "SQLite extension not found in resources at {}" ,
127+ resource_path. display( )
128+ ) ;
119129 }
120- Err ( err) => log:: warn!( "Failed to resolve current executable path : {}" , err) ,
130+ Err ( err) => log:: warn!( "Failed to resolve resource directory : {}" , err) ,
121131 }
122132
123133 let manifest_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
@@ -126,9 +136,10 @@ fn resolve_extension_path(_app_handle: &AppHandle) -> Option<PathBuf> {
126136 . and_then ( Path :: parent)
127137 . unwrap_or ( & manifest_dir) ;
128138 let target_dir = workspace_root. join ( "target" ) ;
129- let lib_name = extension_lib_name ( ) ;
130- candidates. push ( ( "debug build" , target_dir. join ( "debug" ) . join ( & lib_name) ) ) ;
131- candidates. push ( ( "release build" , target_dir. join ( "release" ) . join ( & lib_name) ) ) ;
139+ let candidates = [
140+ ( "debug build" , target_dir. join ( "debug" ) . join ( & lib_name) ) ,
141+ ( "release build" , target_dir. join ( "release" ) . join ( & lib_name) ) ,
142+ ] ;
132143
133144 for ( label, path) in candidates {
134145 log:: debug!( "Checking {} SQLite extension at {}" , label, path. display( ) ) ;
@@ -139,7 +150,7 @@ fn resolve_extension_path(_app_handle: &AppHandle) -> Option<PathBuf> {
139150 }
140151
141152 log:: warn!(
142- "SQLite extension not found. Checked bundled resource and build outputs in {}" ,
153+ "SQLite extension not found. Checked bundled resources and build outputs in {}" ,
143154 target_dir. display( )
144155 ) ;
145156 None
0 commit comments