Skip to content

Commit

Permalink
Fill in extension view info when control file is absent (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianstanton authored Dec 26, 2023
1 parent 459f68b commit 11e5b49
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions registry/src/v1/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,40 @@ pub fn extract_extension_view(
) -> anyhow::Result<Vec<ExtensionView>> {
let control_files = extract_control_files(tar_gz)?;

let extension_views = control_files
let mut extension_views: Vec<ExtensionView> = control_files
.into_iter()
.map(|control_file| ExtensionView {
extension_name: control_file.extension_name,
extension_name: control_file.extension_name.clone(),
version: control_file.default_version.unwrap_or_default(),
trunk_project_name: new_extension.name.to_string(),
dependencies_extension_names: control_file.dependencies,
// TODO: should we clone this for every extension in a Trunk project?
loadable_libraries: new_extension.libraries.clone(),
configurations: new_extension.configurations.clone(),
control_file: if control_file.content.is_none() {
Some(ControlFileMetadata {
absent: true,
content: None,
})
} else {
Some(ControlFileMetadata {
absent: false,
content: control_file.content,
})
},
control_file: Some(ControlFileMetadata {
absent: false,
content: control_file.content,
}),
})
.collect();

// If no control files found, we still want to return extension view information we have available.
// This includes control_file.absent = true and control_file.content = None
if extension_views.is_empty() {
extension_views.push(ExtensionView {
extension_name: new_extension.extension_name.clone().unwrap_or_default(),
version: new_extension.vers.to_string(),
trunk_project_name: new_extension.name.to_string(),
dependencies_extension_names: None,
loadable_libraries: new_extension.libraries.clone(),
configurations: new_extension.configurations.clone(),
control_file: Some(ControlFileMetadata {
absent: true,
content: None,
}),
});
}

Ok(extension_views)
}

Expand Down

0 comments on commit 11e5b49

Please sign in to comment.