@@ -103,15 +103,15 @@ pub async fn import_plugins(version: Option<String>) -> anyhow::Result<()> {
103103 let mut lockfile_plugins = Vec :: new ( ) ;
104104
105105 let mut skipped_plugins = Vec :: new ( ) ;
106- for ( name, filename, version_option, hash ) in & plugins {
106+ for ( name, filename, version_option, _hash ) in & plugins {
107107 debug ! (
108108 "Searching for plugin: name={}, filename={}, version={:?}" ,
109109 name, filename, version_option
110110 ) ;
111111
112112 // Try to find the plugin in sources using search functionality
113113 match find_plugin_source ( name, version_option. as_deref ( ) , minecraft_version) . await {
114- Some ( ( source, plugin_id) ) => {
114+ Some ( ( source, plugin_id, resolved ) ) => {
115115 debug ! (
116116 "Plugin found in source: name={}, source={}, plugin_id={}" ,
117117 name, source, plugin_id
@@ -126,17 +126,15 @@ pub async fn import_plugins(version: Option<String>) -> anyhow::Result<()> {
126126 } ,
127127 ) ;
128128
129- // Add to lockfile with local file info
130- // The URL and hash will be updated when user runs 'lock' command
131- // We use the local file hash for now to maintain integrity
132- let source_clone = source. clone ( ) ;
129+ // Use resolved URL and hash from the source, but keep local filename
130+ // since that's what the user actually has in their plugins directory
133131 lockfile_plugins. push ( LockedPlugin {
134132 name : name. clone ( ) ,
135133 source,
136- version : version_option . clone ( ) . unwrap_or_else ( || filename . clone ( ) ) ,
137- file : filename. clone ( ) ,
138- url : format ! ( "{}://{}" , source_clone , plugin_id ) , // Placeholder, will be resolved during lock
139- hash : hash. clone ( ) , // Local file hash, will be updated during lock
134+ version : resolved . version . clone ( ) ,
135+ file : filename. clone ( ) , // Keep local filename
136+ url : resolved . url . clone ( ) , // Use resolved URL
137+ hash : resolved . hash . clone ( ) , // Use resolved hash
140138 } ) ;
141139 }
142140 None => {
@@ -200,12 +198,12 @@ pub async fn import_plugins(version: Option<String>) -> anyhow::Result<()> {
200198}
201199
202200/// Search for a plugin across all sources in priority order
203- /// Returns Some((source_name, plugin_id)) if found, None otherwise
201+ /// Returns Some((source_name, plugin_id, resolved_version )) if found, None otherwise
204202async fn find_plugin_source (
205203 plugin_name : & str ,
206204 version : Option < & str > ,
207205 minecraft_version : Option < & str > ,
208- ) -> Option < ( String , String ) > {
206+ ) -> Option < ( String , String , crate :: sources :: ResolvedVersion ) > {
209207 let sources = REGISTRY . get_priority_order ( ) ;
210208 let timeout_duration = Duration :: from_secs ( 180 ) ; // 3 minutes
211209
@@ -218,7 +216,8 @@ async fn find_plugin_source(
218216 minecraft_version : Option < String > ,
219217 timeout_duration : Duration ,
220218 priority : usize ,
221- ) -> Result < ( String , String , usize ) , ( String , String , usize ) > {
219+ ) -> Result < ( String , String , crate :: sources:: ResolvedVersion , usize ) , ( String , String , usize ) >
220+ {
222221 debug ! (
223222 "Searching source '{}' for plugin '{}'" ,
224223 source_name, search_id
@@ -232,7 +231,12 @@ async fn find_plugin_source(
232231 let result = timeout ( timeout_duration, resolved_future) . await ;
233232
234233 match result {
235- Ok ( Ok ( _) ) => Ok ( ( source_name. to_string ( ) , search_id. clone ( ) , priority) ) ,
234+ Ok ( Ok ( resolved) ) => Ok ( (
235+ source_name. to_string ( ) ,
236+ search_id. clone ( ) ,
237+ resolved,
238+ priority,
239+ ) ) ,
236240 Ok ( Err ( e) ) => {
237241 // If exact version failed and we have both a version and minecraft_version,
238242 // try again without the version constraint to find the latest compatible version
@@ -246,7 +250,12 @@ async fn find_plugin_source(
246250 source_impl. resolve_version ( & search_id, None , minecraft_version_ref) ;
247251 let retry_result = timeout ( timeout_duration, retry_future) . await ;
248252 match retry_result {
249- Ok ( Ok ( _) ) => Ok ( ( source_name. to_string ( ) , search_id. clone ( ) , priority) ) ,
253+ Ok ( Ok ( resolved) ) => Ok ( (
254+ source_name. to_string ( ) ,
255+ search_id. clone ( ) ,
256+ resolved,
257+ priority,
258+ ) ) ,
250259 Ok ( Err ( _) ) | Err ( _) => {
251260 Err ( ( source_name. to_string ( ) , search_id. clone ( ) , priority) )
252261 }
@@ -323,21 +332,23 @@ async fn find_plugin_source(
323332 let mut successful_results: Vec < _ > = results
324333 . into_iter ( )
325334 . filter_map ( |result| match result {
326- Ok ( ( source_name, plugin_id, priority) ) => Some ( ( source_name, plugin_id, priority) ) ,
335+ Ok ( ( source_name, plugin_id, resolved, priority) ) => {
336+ Some ( ( source_name, plugin_id, resolved, priority) )
337+ }
327338 Err ( _) => None ,
328339 } )
329340 . collect ( ) ;
330341
331342 // Sort by priority (lower number = higher priority)
332- successful_results. sort_by_key ( |( _, _, priority) | * priority) ;
343+ successful_results. sort_by_key ( |( _, _, _ , priority) | * priority) ;
333344
334345 // Return the first successful result
335- if let Some ( ( source_name, plugin_id, _) ) = successful_results. first ( ) {
346+ if let Some ( ( source_name, plugin_id, resolved , _) ) = successful_results. first ( ) {
336347 debug ! (
337348 "Plugin found in source: plugin={}, source={}, plugin_id={}" ,
338349 plugin_name, source_name, plugin_id
339350 ) ;
340- return Some ( ( source_name. to_string ( ) , plugin_id. clone ( ) ) ) ;
351+ return Some ( ( source_name. to_string ( ) , plugin_id. clone ( ) , resolved . clone ( ) ) ) ;
341352 }
342353
343354 // Not found in any source
0 commit comments