diff --git a/daemon/src/diag.rs b/daemon/src/diag.rs index a50f665..1340a36 100644 --- a/daemon/src/diag.rs +++ b/daemon/src/diag.rs @@ -170,9 +170,10 @@ impl DiagTask { lat, lon, }; - let json = serde_json::to_string(&record)?; + let mut json = serde_json::to_vec(&record)?; + json.push(b'\n'); gps_file - .write_all(format!("{json}\n").as_bytes()) + .write_all(&json) .await .map_err(RecordingStoreError::WriteFileError)?; } diff --git a/daemon/src/gps.rs b/daemon/src/gps.rs index b41622a..303e3e9 100644 --- a/daemon/src/gps.rs +++ b/daemon/src/gps.rs @@ -122,22 +122,21 @@ pub async fn post_gps( lat: gps_data.latitude, lon: gps_data.longitude, }; - let json = serde_json::to_string(&record).map_err(|e| { + let mut json = serde_json::to_vec(&record).map_err(|e| { error!("failed to serialize GPS record: {e}"); ( StatusCode::INTERNAL_SERVER_ERROR, format!("failed to serialize GPS record: {e}"), ) })?; - file.write_all(format!("{json}\n").as_bytes()) - .await - .map_err(|e| { - error!("failed to write GPS record to sidecar: {e}"); - ( - StatusCode::INTERNAL_SERVER_ERROR, - format!("failed to write GPS record to sidecar: {e}"), - ) - })?; + json.push(b'\n'); + file.write_all(&json).await.map_err(|e| { + error!("failed to write GPS record to sidecar: {e}"); + ( + StatusCode::INTERNAL_SERVER_ERROR, + format!("failed to write GPS record to sidecar: {e}"), + ) + })?; } Ok(None) => error!("GPS sidecar directory not found, cannot write GPS record"), Err(e) => {