fix: avoid using terrors::OneOf across an await boundary
All checks were successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful

OneOf appears to not be Send
This commit is contained in:
Paul Campbell 2024-04-12 10:14:10 +01:00
parent 8ed942a501
commit 0b427f1d4c
3 changed files with 16 additions and 8 deletions

View file

@ -1,5 +1,4 @@
use kxio::network;
use terrors::OneOf;
use tracing::{error, info, warn};
use crate::server;
@ -13,7 +12,7 @@ pub async fn get_commit_histories(
repo_details: &server::config::RepoDetails,
config: &server::config::RepoConfig,
net: &kxio::network::Network,
) -> Result<CommitHistories, OneOf<(network::NetworkError,)>> {
) -> Result<CommitHistories, network::NetworkError> {
let main = (get_commit_history(repo_details, &config.branches().main(), vec![], net).await)?;
let main_head = main[0].clone();
let next = (get_commit_history(
@ -47,7 +46,7 @@ async fn get_commit_history(
branch_name: &BranchName,
find_commits: Vec<forge::Commit>,
net: &kxio::network::Network,
) -> Result<Vec<forge::Commit>, OneOf<(network::NetworkError,)>> {
) -> Result<Vec<forge::Commit>, network::NetworkError> {
let hostname = &repo_details.forge.hostname;
let path = &repo_details.repo;
let token = &repo_details.forge.token;
@ -72,11 +71,7 @@ async fn get_commit_history(
None,
network::NetRequestLogging::None,
);
let result = net.get::<Vec<Commit>>(request).await;
let response = result.map_err(|e| {
error!(?e, "Failed to get commit history");
OneOf::new(e)
})?;
let response = net.get::<Vec<Commit>>(request).await?;
let commits = response
.response_body()
.unwrap_or_default()

View file

@ -2,6 +2,9 @@ use std::fmt::{Display, Formatter};
pub mod forgejo;
#[cfg(test)]
mod tests;
#[derive(Clone, Debug)]
pub struct CommitHistories {
pub main: Vec<Commit>,

10
src/server/forge/tests.rs Normal file
View file

@ -0,0 +1,10 @@
use kxio::network::NetworkError;
use crate::server::forge::CommitHistories;
#[test]
const fn test_is_send() {
const fn assert_send<T: Send>() {}
assert_send::<CommitHistories>();
assert_send::<NetworkError>();
}