Skip to content

Commit

Permalink
registry(v1): insert control file metadata correctly in all cases (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrmiguel authored Jan 4, 2024
1 parent ecaf667 commit 5d0c9d5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions registry/src/v1/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,8 @@ impl Registry {
.await?;

// 8. Insert control file metadata
if let Some(control_file) = &extension.control_file {
self.insert_control_file(extension_version_id, control_file.clone())
.await?;
}
self.insert_control_file(extension_version_id, extension.control_file.as_ref())
.await?;
}

Ok(())
Expand Down Expand Up @@ -568,8 +566,11 @@ impl Registry {
async fn insert_control_file(
&self,
extension_version_id: i32,
control_file: ControlFileMetadata,
control_file: Option<&ControlFileMetadata>,
) -> Result {
let absent = control_file.is_none();
let content = control_file.and_then(|control_file| control_file.content.as_ref());

sqlx::query!(
"INSERT INTO v1.control_file (extension_version_id, absent, content)
VALUES ($1, $2, $3)
Expand All @@ -578,8 +579,8 @@ impl Registry {
absent = EXCLUDED.absent,
content = EXCLUDED.content",
extension_version_id,
control_file.absent,
control_file.content,
absent,
content,
)
.execute(&self.pool)
.await?;
Expand Down

0 comments on commit 5d0c9d5

Please sign in to comment.