Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/crates_io_tarball/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ mod tests {

#[tokio::test]
async fn process_tarball_test_incorrect_manifest_casing() {
let process = |file| async move {
let process = async |file| {
let tarball = TarballBuilder::new()
.add_file(&format!("foo-0.0.1/{file}"), MANIFEST)
.build();
Expand All @@ -343,7 +343,7 @@ mod tests {

#[tokio::test]
async fn process_tarball_test_multiple_manifests() {
let process = |files: Vec<_>| async move {
let process = async |files: Vec<_>| {
let tarball = files
.iter()
.fold(TarballBuilder::new(), |builder, file| {
Expand Down
2 changes: 1 addition & 1 deletion crates/crates_io_worker/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<Context: Clone + Send + Sync + 'static> Worker<Context> {
let job_id = job.id;
debug!("Running job…");

let future = with_sentry_transaction(&job.job_type, || async {
let future = with_sentry_transaction(&job.job_type, async || {
let run_task_fn = job_registry
.get(&job.job_type)
.ok_or_else(|| anyhow!("Unknown job type {}", job.job_type))?;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/krate/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ mod tests {

#[tokio::test]
async fn test_query_params() -> anyhow::Result<()> {
let check = |uri| async move {
let check = async |uri| {
let request = Request::builder().uri(uri).body(())?;
let (mut parts, _) = request.into_parts();
Ok::<_, anyhow::Error>(parts.extract::<DeleteQueryParams>().await?)
Expand Down
8 changes: 4 additions & 4 deletions src/controllers/krate/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,11 +527,11 @@ pub async fn publish(app: AppState, req: Parts, body: Body) -> AppResult<Json<Go
git_index_job.enqueue(conn),
sparse_index_job.enqueue(conn),
publish_notifications_job.enqueue(conn),
crate_feed_job.enqueue(conn).or_else(|error| async move {
crate_feed_job.enqueue(conn).or_else(async |error| {
error!("Failed to enqueue `rss::SyncCrateFeed` job: {error}");
Ok::<_, EnqueueError>(None)
}),
updates_feed_job.enqueue(conn).or_else(|error| async move {
updates_feed_job.enqueue(conn).or_else(async |error| {
error!("Failed to enqueue `rss::SyncUpdatesFeed` job: {error}");
Ok::<_, EnqueueError>(None)
}),
Expand All @@ -543,11 +543,11 @@ pub async fn publish(app: AppState, req: Parts, body: Body) -> AppResult<Json<Go
let typosquat_job = CheckTyposquat::new(&krate.name);

tokio::try_join!(
crates_feed_job.enqueue(conn).or_else(|error| async move {
crates_feed_job.enqueue(conn).or_else(async |error| {
error!("Failed to enqueue `rss::SyncCratesFeed` job: {error}");
Ok::<_, EnqueueError>(None)
}),
typosquat_job.enqueue(conn).or_else(|error| async move {
typosquat_job.enqueue(conn).or_else(async |error| {
error!("Failed to enqueue `CheckTyposquat` job: {error}");
Ok::<_, EnqueueError>(None)
}),
Expand Down
11 changes: 5 additions & 6 deletions src/middleware/cargo_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,20 @@ mod tests {
use tower::ServiceExt;

fn build_app() -> Router {
let okay = get(|| async { "Everything is okay" });
let teapot = get(|| async { (StatusCode::IM_A_TEAPOT, "I'm a teapot") });
let internal =
get(|| async { (StatusCode::INTERNAL_SERVER_ERROR, "Internal Server Error") });
let okay = get(async || "Everything is okay");
let teapot = get(async || (StatusCode::IM_A_TEAPOT, "I'm a teapot"));
let internal = get(async || (StatusCode::INTERNAL_SERVER_ERROR, "Internal Server Error"));

Router::new()
.route("/api/ok", okay.clone())
.route("/api/teapot", teapot.clone())
.route("/teapot", teapot)
.route("/api/500", internal.clone())
.route("/500", internal)
.route("/api/v1/crates/new", put(|| async { StatusCode::CREATED }))
.route("/api/v1/crates/new", put(async || StatusCode::CREATED))
.route(
"/api/v1/crates/{crate_id}/owners",
get(|| async { StatusCode::INTERNAL_SERVER_ERROR }),
get(async || StatusCode::INTERNAL_SERVER_ERROR),
)
.layer(from_fn_with_state(StatusCodeConfig::AdjustAll, middleware))
}
Expand Down
10 changes: 4 additions & 6 deletions src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,10 @@ pub fn build_axum_router(state: AppState) -> Router<()> {
}

router
.route("/api/openapi.json", get(|| async { Json(openapi) }))
.fallback(|method: Method| async move {
match method {
Method::HEAD => StatusCode::NOT_FOUND.into_response(),
_ => not_found().into_response(),
}
.route("/api/openapi.json", get(async || Json(openapi)))
.fallback(async |method: Method| match method {
Method::HEAD => StatusCode::NOT_FOUND.into_response(),
_ => not_found().into_response(),
})
.with_state(state)
}
2 changes: 1 addition & 1 deletion src/worker/jobs/archive_version_downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ async fn upload(

let directory = directory.as_ref();
let uploaded_dates = futures_util::stream::iter(dates)
.map(|date| async move {
.map(async |date| {
let path = directory.join(format!("{date}.csv"));
let result = upload_file(store, &path).await;
result.map(|_| date).inspect_err(|error| {
Expand Down