X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcheck.go;h=a8a32e2c7899bcb68c4c0f6b23394f72312c2aac;hb=5a9bf58a2638e42f2d42fa4d43c363a664fe8198;hp=ac26e9ce3a322d227ff8530b4a7fe35c8b9442d8;hpb=745d9fafe84b0745b84d93900722216dde6b88cc;p=nncp.git diff --git a/src/check.go b/src/check.go index ac26e9c..a8a32e2 100644 --- a/src/check.go +++ b/src/check.go @@ -21,6 +21,7 @@ import ( "bufio" "bytes" "errors" + "fmt" "io" "log" "os" @@ -45,26 +46,30 @@ func Check(src io.Reader, checksum []byte, les LEs, showPrgrs bool) (bool, error func (ctx *Ctx) checkXxIsBad(nodeId *NodeId, xx TRxTx) bool { isBad := false for job := range ctx.Jobs(nodeId, xx) { + pktName := Base32Codec.EncodeToString(job.HshValue[:]) les := LEs{ {"XX", string(xx)}, {"Node", nodeId}, - {"Pkt", Base32Codec.EncodeToString(job.HshValue[:])}, + {"Pkt", pktName}, {"FullSize", job.Size}, } + logMsg := func(les LEs) string { + return fmt.Sprintf("Checking: %s/%s/%s", nodeId, string(xx), pktName) + } fd, err := os.Open(job.Path) if err != nil { - ctx.LogE("check", les, err, "") + ctx.LogE("checking", les, err, logMsg) return true } gut, err := Check(fd, job.HshValue[:], les, ctx.ShowPrgrs) fd.Close() // #nosec G104 if err != nil { - ctx.LogE("check", les, err, "") + ctx.LogE("checking", les, err, logMsg) return true } if !gut { isBad = true - ctx.LogE("check", les, errors.New("bad"), "") + ctx.LogE("checking", les, errors.New("bad"), logMsg) } } return isBad