Skip to content

Commit d78346d

Browse files
committed
fix(server): invalidate CloudFront for build routes on new build
1 parent 8862e15 commit d78346d

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

airborne_server/src/build.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,9 +1011,30 @@ async fn build(
10111011
}
10121012
}
10131013

1014+
// --- Step 6: Purge the edge cache so clients see the new version ---
1015+
invalidate_build_cf(&state, &org, &app).await;
1016+
10141017
Ok(new_build_version)
10151018
}
10161019

1020+
/// Invalidate the CloudFront cache for an application's `/build` routes.
1021+
async fn invalidate_build_cf(state: &web::Data<AppState>, org: &str, app: &str) {
1022+
let path = format!("/build/{}/{}*", org, app);
1023+
1024+
if let Err(e) = release::utils::invalidate_cf(
1025+
&state.cf_client,
1026+
path,
1027+
&state.env.cloudfront_distribution_id,
1028+
)
1029+
.await
1030+
{
1031+
info!(
1032+
"Failed to invalidate CloudFront cache for build {}/{}: {:?}",
1033+
org, app, e
1034+
);
1035+
}
1036+
}
1037+
10171038
async fn extract_args(
10181039
path: web::Path<(String, String)>,
10191040
state: web::Data<AppState>,

0 commit comments

Comments
 (0)