/*
NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2019 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
ctx.LogE("nncp-reass", nncp.SDS{"path": path}, err, "bad meta file")
return false
}
- fd.Close()
+ fd.Close() // #nosec G104
if metaPkt.Magic != nncp.MagicNNCPMv1 {
ctx.LogE("nncp-reass", nncp.SDS{"path": path}, nncp.BadMagic, "")
return false
if err != nil {
log.Fatalln(err)
}
- if _, err = nncp.CopyProgressed(hsh, bufio.NewReader(fd), nncp.SDS{
- "pkt": chunkPath,
- "fullsize": fi.Size(),
- }, ctx.ShowPrgrs); err != nil {
+ if _, err = nncp.CopyProgressed(
+ hsh, bufio.NewReader(fd), "check",
+ nncp.SDS{
+ "pkt": chunkPath,
+ "fullsize": fi.Size(),
+ },
+ ctx.ShowPrgrs,
+ ); err != nil {
log.Fatalln(err)
}
- fd.Close()
+ fd.Close() // #nosec G104
if bytes.Compare(hsh.Sum(nil), metaPkt.Checksums[chunkNum][:]) != 0 {
ctx.LogE(
"nncp-reass",
if err != nil {
log.Fatalln("Can not stat file:", err)
}
- if _, err = nncp.CopyProgressed(dstW, bufio.NewReader(fd), nncp.SDS{
- "pkt": chunkPath,
- "fullsize": fi.Size(),
- }, ctx.ShowPrgrs); err != nil {
+ if _, err = nncp.CopyProgressed(
+ dstW, bufio.NewReader(fd), "reass",
+ nncp.SDS{
+ "pkt": chunkPath,
+ "fullsize": fi.Size(),
+ },
+ ctx.ShowPrgrs,
+ ); err != nil {
log.Fatalln(err)
}
- fd.Close()
+ fd.Close() // #nosec G104
if !keep {
if err = os.Remove(chunkPath); err != nil {
ctx.LogE("nncp-reass", nncp.SdsAdd(sds, nncp.SDS{"chunk": chunkNum}), err, "")
if err = tmp.Sync(); err != nil {
log.Fatalln("Can not sync:", err)
}
- tmp.Close()
+ if err = tmp.Close(); err != nil {
+ log.Fatalln("Can not close:", err)
+ }
}
ctx.LogD("nncp-reass", sds, "written")
if !keep {
return nil
}
fis, err := dir.Readdir(0)
- dir.Close()
+ dir.Close() // #nosec G104
if err != nil {
ctx.LogE("nncp-reass", nncp.SDS{"path": dirPath}, err, "")
return nil