- if _, err = io.CopyN(tmp.W, bufio.NewReader(fd), fiInt.Size()); err != nil {
- ctx.LogE("nncp-xfer", nncp.SdsAdd(sds, nncp.SDS{"err": err}), "copy")
+ r, w := io.Pipe()
+ go func() {
+ _, err := io.CopyN(w, bufio.NewReader(fd), fiInt.Size())
+ if err == nil {
+ err = w.Close()
+ }
+ if err != nil {
+ ctx.LogE("xfer-rx", les, err, logMsg)
+ w.CloseWithError(err) // #nosec G104
+ }
+ }()
+ if _, err = nncp.CopyProgressed(
+ tmp.W, r, "Rx",
+ append(
+ les,
+ nncp.LE{K: "Pkt", V: filename},
+ nncp.LE{K: "FullSize", V: fiInt.Size()},
+ ),
+ ctx.ShowPrgrs,
+ ); err != nil {
+ ctx.LogE("xfer-rx", les, err, logMsg)