ctx.NodeName(nodeId), filename,
)
}
+ if _, err = os.Stat(filepath.Join(
+ ctx.Spool,
+ nodeId.String(),
+ string(nncp.TRx),
+ nncp.SeenDir,
+ fiInt.Name(),
+ )); err == nil || !os.IsNotExist(err) {
+ ctx.LogI("xfer-rx-seen", les, func(les nncp.LEs) string {
+ return logMsg(les) + ": packet already seen"
+ })
+ if !*keep {
+ if err = os.Remove(filename); err != nil {
+ ctx.LogE("xfer-rx-remove", les, err, logMsg)
+ isBad = true
+ }
+ }
+ continue
+ }
fd, err := os.Open(filename)
if err != nil {
ctx.LogE("xfer-rx-open", les, err, func(les nncp.LEs) string {
fd.Close()
continue
}
- if _, err = fd.Seek(0, 0); err != nil {
+ if _, err = fd.Seek(0, io.SeekStart); err != nil {
log.Fatalln(err)
}
tmp, err := ctx.NewTmpFileWHash()
}
r, w := io.Pipe()
go func() {
- _, err := io.CopyN(w, bufio.NewReader(fd), fiInt.Size())
+ _, err := io.CopyN(
+ w, bufio.NewReaderSize(fd, nncp.MTHBlockSize), fiInt.Size(),
+ )
if err == nil {
err = w.Close()
}
w.CloseWithError(err)
}
}()
- if _, err = nncp.CopyProgressed(
+ _, err = nncp.CopyProgressed(
tmp.W, r, "Rx",
append(
les,
nncp.LE{K: "FullSize", V: fiInt.Size()},
),
ctx.ShowPrgrs,
- ); err != nil {
+ )
+ fd.Close()
+ if err != nil {
ctx.LogE("xfer-rx", les, err, logMsg)
+ tmp.Cancel()
isBad = true
+ continue
}
- fd.Close()
- if isBad {
+ if err = tmp.W.Flush(); err != nil {
+ ctx.LogE("xfer-rx", les, err, logMsg)
tmp.Cancel()
+ isBad = true
+ continue
+ }
+ if tmp.Checksum() != fiInt.Name() {
+ ctx.LogE("xfer-rx", les, errors.New("checksum mismatch"), logMsg)
+ tmp.Cancel()
+ isBad = true
continue
}
if err = tmp.Commit(filepath.Join(
})
continue
}
- if _, err = os.Stat(filepath.Join(
- dstPath, nncp.SeenDir, pktName,
- )); err == nil || !os.IsNotExist(err) {
- ctx.LogD("xfer-tx-seen", les, func(les nncp.LEs) string {
- return logMsg(les) + ": already seen"
- })
- continue
- }
tmp, err := nncp.TempFile(dstPath, "xfer")
if err != nil {
ctx.LogE("xfer-tx-mktemp", les, err, func(les nncp.LEs) string {
}
bufW := bufio.NewWriter(tmp)
copied, err := nncp.CopyProgressed(
- bufW, bufio.NewReader(fd), "Tx",
+ bufW, bufio.NewReaderSize(fd, nncp.MTHBlockSize), "Tx",
append(les, nncp.LE{K: "FullSize", V: job.Size}),
ctx.ShowPrgrs,
)
isBad = true
continue
}
- if err = tmp.Sync(); err != nil {
- tmp.Close()
- ctx.LogE("xfer-tx-sync", les, err, func(les nncp.LEs) string {
- return logMsg(les) + ": syncing"
- })
- isBad = true
- continue
+ if !nncp.NoSync {
+ if err = tmp.Sync(); err != nil {
+ tmp.Close()
+ ctx.LogE("xfer-tx-sync", les, err, func(les nncp.LEs) string {
+ return logMsg(les) + ": syncing"
+ })
+ isBad = true
+ continue
+ }
}
if err = tmp.Close(); err != nil {
ctx.LogE("xfer-tx-close", les, err, func(les nncp.LEs) string {