From 56e5d08efff132f159331379607d17c03eef1dbf Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 26 May 2021 22:49:52 +1000 Subject: [PATCH] Log failure to complete metadata --- client.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 9506cfd2..cab4c234 100644 --- a/client.go +++ b/client.go @@ -1058,7 +1058,15 @@ func (cl *Client) gotMetadataExtensionMsg(payload []byte, t *Torrent, c *PeerCon } t.saveMetadataPiece(piece, payload[begin:]) c.lastUsefulChunkReceived = time.Now() - return t.maybeCompleteMetadata() + err = t.maybeCompleteMetadata() + if err != nil { + // Log this at the Torrent-level, as we don't partition metadata by Peer yet, so we + // don't know who to blame. TODO: Also errors can be returned here that aren't related + // to verifying metadata, which should be fixed. This should be tagged with metadata, so + // log consumers can filter for this message. + t.logger.WithDefaultLevel(log.Warning).Printf("error completing metadata: %v", err) + } + return err case pp.RequestMetadataExtensionMsgType: if !t.haveMetadataPiece(piece) { c.post(t.newMetadataExtensionMessage(c, pp.RejectMetadataExtensionMsgType, d["piece"], nil))