fetch: log handshake error

When performing a handshake, the error source is hidden in the error
variant and never shown.

To get insight as to what the error was, it is logged when it is
encounterd.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny 2024-03-07 11:28:10 +00:00 committed by cloudhead
parent 6efd0d97a5
commit c02ff1e47e
No known key found for this signature in database
1 changed files with 13 additions and 8 deletions

View File

@ -9,6 +9,7 @@ mod refs;
mod stage;
mod state;
use gix_protocol::handshake;
pub use handle::Handle;
pub use policy::{Allowed, BlockList, Scope};
use radicle::storage::ReadRepository as _;
@ -62,10 +63,7 @@ where
if local == remote {
return Err(Error::ReplicateSelf);
}
let handshake = handle
.transport
.handshake()
.map_err(|err| Error::Handshake { err })?;
let handshake = perform_handshake(handle)?;
let state = FetchState::default();
// N.b. ensure that we ignore the local peer's key.
@ -99,10 +97,7 @@ where
if *handle.local() == remote {
return Err(Error::ReplicateSelf);
}
let handshake = handle
.transport
.handshake()
.map_err(|err| Error::Handshake { err })?;
let handshake = perform_handshake(handle)?;
let state = FetchState::default();
let result = state
.run(handle, &handshake, limit, remote, None)
@ -116,3 +111,13 @@ where
);
result
}
fn perform_handshake<S>(handle: &mut Handle<S>) -> Result<handshake::Outcome, Error>
where
S: transport::ConnectionStream,
{
handle.transport.handshake().map_err(|err| {
log::warn!(target: "fetch", "Failed to perform handshake: {err}");
Error::Handshake { err }
})
}