From 673dfbbd5738bf27fec2e3a7225798696c684a20 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 10 Jul 2025 16:29:21 +1000 Subject: [PATCH] cmd/torrent: Dump client stats atomically --- cmd/torrent/download.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/torrent/download.go b/cmd/torrent/download.go index cbc0a9dc..e05b3242 100644 --- a/cmd/torrent/download.go +++ b/cmd/torrent/download.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "context" "expvar" "fmt" @@ -478,7 +479,9 @@ func downloadErr(ctx context.Context, flags downloadFlags) error { } } fmt.Printf("chunks received: %v\n", &torrent.ChunksReceived) - spew.Dump(client.Stats()) + var buf bytes.Buffer + spew.Fdump(&buf, client.Stats()) + os.Stdout.Write(buf.Bytes()) clStats := client.ConnStats() sentOverhead := clStats.BytesWritten.Int64() - clStats.BytesWrittenData.Int64() log.Printf( -- 2.51.0