From 61d6f2b2976753d2c115334d641104b0f0c8b60c Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 27 May 2025 17:52:24 +1000 Subject: [PATCH] Fix panic in Client.WriteStatus if info isn't available --- client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 709f74e3..76694ec9 100644 --- a/client.go +++ b/client.go @@ -186,7 +186,13 @@ func (cl *Client) WriteStatus(_w io.Writer) { slices.SortFunc(torrentsSlice, func(a, b *Torrent) int { return cmp.Or( compareBool(a.haveInfo(), b.haveInfo()), - -cmp.Compare(a.bytesLeft(), b.bytesLeft()), + func() int { + if a.haveInfo() && b.haveInfo() { + return -cmp.Compare(a.bytesLeft(), b.bytesLeft()) + } else { + return 0 + } + }(), cmp.Compare(a.canonicalShortInfohash().AsString(), b.canonicalShortInfohash().AsString()), ) }) -- 2.51.0