0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-08-27 18:35:07 +00:00

fix: prevent reporting http errors in sync_offline

resolves #1919
This commit is contained in:
Levy A.
2025-01-17 00:31:41 -03:00
parent 573ba92b50
commit 111c27762a

View File

@@ -478,9 +478,7 @@ impl Database {
Err(Error::Sync(err)) => {
// Retry the sync because we are ahead of the server and we need to push some older
// frames.
if let Some(SyncError::InvalidPushFrameNoLow(_, _)) =
err.downcast_ref::<SyncError>()
{
if let Some(SyncError::InvalidPushFrameNoLow(_, _)) = err.downcast_ref() {
tracing::debug!("got InvalidPushFrameNo, retrying push");
self.try_push(&mut sync_ctx, &conn).await
} else {
@@ -492,6 +490,22 @@ impl Database {
} else {
self.try_pull(&mut sync_ctx, &conn).await
}
.or_else(|err| {
let Error::Sync(err) = err else {
return Err(err);
};
// TODO(levy): upcasting should be done *only* at the API boundary, doing this in
// internal code just sucks.
let Some(SyncError::HttpDispatch(_)) = err.downcast_ref() else {
return Err(Error::Sync(err));
};
Ok(crate::database::Replicated {
frame_no: None,
frames_synced: 0,
})
})
}
#[cfg(feature = "sync")]