log.Fatalln("Can not open file:", err)
}
var metaPkt nncp.ChunkedMeta
+ les := nncp.LEs{{K: "Path", V: path}}
if _, err = xdr.Unmarshal(fd, &metaPkt); err != nil {
- ctx.LogE("nncp-reass", nncp.SDS{"path": path}, err, "bad meta file")
+ ctx.LogE("nncp-reass", les, err, "bad meta file")
return false
}
fd.Close() // #nosec G104
if metaPkt.Magic != nncp.MagicNNCPMv1 {
- ctx.LogE("nncp-reass", nncp.SDS{"path": path}, nncp.BadMagic, "")
+ ctx.LogE("nncp-reass", les, nncp.BadMagic, "")
return false
}
metaName := filepath.Base(path)
if !strings.HasSuffix(metaName, nncp.ChunkedSuffixMeta) {
- ctx.LogE("nncp-reass", nncp.SDS{"path": path}, errors.New("invalid filename suffix"), "")
+ ctx.LogE("nncp-reass", les, errors.New("invalid filename suffix"), "")
return false
}
mainName := strings.TrimSuffix(metaName, nncp.ChunkedSuffixMeta)
allChunksExist := true
for chunkNum, chunkPath := range chunksPaths {
fi, err := os.Stat(chunkPath)
+ lesChunk := append(les, nncp.LE{K: "Chunk", V: chunkNum})
if err != nil && os.IsNotExist(err) {
- ctx.LogI("nncp-reass", nncp.SDS{"path": path, "chunk": chunkNum}, "missing")
+ ctx.LogI("nncp-reass", lesChunk, "missing")
allChunksExist = false
continue
}
badSize = uint64(fi.Size()) != metaPkt.ChunkSize
}
if badSize {
- ctx.LogE(
- "nncp-reass",
- nncp.SDS{"path": path, "chunk": chunkNum},
- errors.New("invalid size"), "",
- )
+ ctx.LogE("nncp-reass", lesChunk, errors.New("invalid size"), "")
allChunksExist = false
}
}
}
if _, err = nncp.CopyProgressed(
hsh, bufio.NewReader(fd), "check",
- nncp.SDS{
- "pkt": chunkPath,
- "fullsize": fi.Size(),
+ nncp.LEs{
+ {K: "Pkt", V: chunkPath},
+ {K: "FullSize", V: fi.Size()},
},
ctx.ShowPrgrs,
); err != nil {
if bytes.Compare(hsh.Sum(nil), metaPkt.Checksums[chunkNum][:]) != 0 {
ctx.LogE(
"nncp-reass",
- nncp.SDS{"path": path, "chunk": chunkNum},
+ nncp.LEs{{K: "Path", V: path}, {K: "Chunk", V: chunkNum}},
errors.New("checksum is bad"), "",
)
allChecksumsGood = false
return false
}
if dryRun {
- ctx.LogI("nncp-reass", nncp.SDS{"path": path}, "ready")
+ ctx.LogI("nncp-reass", nncp.LEs{{K: "path", V: path}}, "ready")
return true
}
var dst io.Writer
var tmp *os.File
- var sds nncp.SDS
if stdout {
dst = os.Stdout
- sds = nncp.SDS{"path": path}
+ les = nncp.LEs{{K: "path", V: path}}
} else {
tmp, err = nncp.TempFile(mainDir, "reass")
if err != nil {
log.Fatalln(err)
}
- sds = nncp.SDS{"path": path, "tmp": tmp.Name()}
- ctx.LogD("nncp-reass", sds, "created")
+ les = nncp.LEs{{K: "path", V: path}, {K: "Tmp", V: tmp.Name()}}
+ ctx.LogD("nncp-reass", les, "created")
dst = tmp
}
dstW := bufio.NewWriter(dst)
}
if _, err = nncp.CopyProgressed(
dstW, bufio.NewReader(fd), "reass",
- nncp.SDS{
- "pkt": chunkPath,
- "fullsize": fi.Size(),
+ nncp.LEs{
+ {K: "Pkt", V: chunkPath},
+ {K: "FullSize", V: fi.Size()},
},
ctx.ShowPrgrs,
); err != nil {
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, "")
+ ctx.LogE("nncp-reass", append(les, nncp.LE{K: "Chunk", V: chunkNum}), err, "")
hasErrors = true
}
}
log.Fatalln("Can not close:", err)
}
}
- ctx.LogD("nncp-reass", sds, "written")
+ ctx.LogD("nncp-reass", les, "written")
if !keep {
if err = os.Remove(path); err != nil {
- ctx.LogE("nncp-reass", sds, err, "")
+ ctx.LogE("nncp-reass", les, err, "")
hasErrors = true
}
}
if stdout {
- ctx.LogI("nncp-reass", nncp.SDS{"path": path}, "done")
+ ctx.LogI("nncp-reass", nncp.LEs{{K: "Path", V: path}}, "done")
return !hasErrors
}
if err = nncp.DirSync(mainDir); err != nil {
log.Fatalln(err)
}
- ctx.LogI("nncp-reass", nncp.SDS{"path": path}, "done")
+ ctx.LogI("nncp-reass", nncp.LEs{{K: "Path", V: path}}, "done")
return !hasErrors
}
dir, err := os.Open(dirPath)
defer dir.Close()
if err != nil {
- ctx.LogE("nncp-reass", nncp.SDS{"path": dirPath}, err, "")
+ ctx.LogE("nncp-reass", nncp.LEs{{K: "Path", V: dirPath}}, err, "")
return nil
}
fis, err := dir.Readdir(0)
dir.Close() // #nosec G104
if err != nil {
- ctx.LogE("nncp-reass", nncp.SDS{"path": dirPath}, err, "")
+ ctx.LogE("nncp-reass", nncp.LEs{{K: "Path", V: dirPath}}, err, "")
return nil
}
metaPaths := make([]string, 0)