]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/check.go
Do not keep files opened
[nncp.git] / src / check.go
index 731e86937c55cb7b2840bbad3d2a1e67cca17398..b2ea671325d0a027b956e05286a0bda4dd36d6f3 100644 (file)
@@ -23,6 +23,7 @@ import (
        "errors"
        "io"
        "log"
+       "os"
 
        "golang.org/x/crypto/blake2b"
 )
@@ -47,8 +48,13 @@ func (ctx *Ctx) checkXxIsBad(nodeId *NodeId, xx TRxTx) bool {
                        {"Pkt", Base32Codec.EncodeToString(job.HshValue[:])},
                        {"FullSize", job.Size},
                }
-               gut, err := Check(job.Fd, job.HshValue[:], les, ctx.ShowPrgrs)
-               job.Fd.Close() // #nosec G104
+               fd, err := os.Open(job.Path)
+               if err != nil {
+                       ctx.LogE("check", les, err, "")
+                       return true
+               }
+               gut, err := Check(fd, job.HshValue[:], les, ctx.ShowPrgrs)
+               fd.Close() // #nosec G104
                if err != nil {
                        ctx.LogE("check", les, err, "")
                        return true