mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2025-12-11 20:15:30 +01:00
refactor: streamline handling of WatermarkExchangeResponse in SyncProtocolHandler
- Simplified the processing of WatermarkExchangeResponse messages to ensure they are only handled via the bidirectional stream. - Added a warning log for unexpected responses, improving visibility into potential misuse of the sync request mechanism. - Removed unnecessary parameters from the response handling, enhancing code clarity and maintainability.
This commit is contained in:
parent
be33d4a6b9
commit
fe97fc2390
@ -475,42 +475,15 @@ impl SyncProtocolHandler {
|
||||
}))
|
||||
}
|
||||
|
||||
SyncMessage::WatermarkExchangeResponse {
|
||||
library_id,
|
||||
device_id,
|
||||
shared_watermark: peer_shared_watermark,
|
||||
needs_state_catchup,
|
||||
needs_shared_catchup,
|
||||
resource_watermarks: peer_resource_watermarks,
|
||||
my_actual_resource_counts: peer_actual_counts,
|
||||
} => {
|
||||
debug!(
|
||||
SyncMessage::WatermarkExchangeResponse { .. } => {
|
||||
// Responses should never arrive as separate messages - they come back
|
||||
// on the bidirectional stream when using send_sync_request().
|
||||
// If we see this, it means someone used send_sync_message() for a request
|
||||
// that expects a response.
|
||||
warn!(
|
||||
from_device = %from_device,
|
||||
peer_shared_watermark = ?peer_shared_watermark,
|
||||
needs_state_catchup = needs_state_catchup,
|
||||
needs_shared_catchup = needs_shared_catchup,
|
||||
peer_resource_count = peer_resource_watermarks.len(),
|
||||
peer_actual_counts = ?peer_actual_counts,
|
||||
"Processing WatermarkExchangeResponse with counts"
|
||||
"Received WatermarkExchangeResponse as incoming message (should arrive via bi-directional stream). Ignoring."
|
||||
);
|
||||
|
||||
peer_sync
|
||||
.on_watermark_exchange_response(
|
||||
from_device,
|
||||
peer_shared_watermark,
|
||||
needs_state_catchup,
|
||||
needs_shared_catchup,
|
||||
peer_resource_watermarks,
|
||||
peer_actual_counts,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
NetworkingError::Protocol(format!(
|
||||
"Failed to handle watermark exchange response: {}",
|
||||
e
|
||||
))
|
||||
})?;
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user