niceRaw = flag.Int("nice", 255, "Minimal required niceness")
rxOnly = flag.Bool("rx", false, "Only receive packets")
txOnly = flag.Bool("tx", false, "Only transfer packets")
- force = flag.Bool("force", false, "Force outbound directories creation")
+ mkdir = flag.Bool("mkdir", false, "Create necessary outbound directories")
keep = flag.Bool("keep", false, "Do not delete transferred packets")
quiet = flag.Bool("quiet", false, "Print only errors")
debug = flag.Bool("debug", false, "Print debug messages")
}
}
- selfPath := filepath.Join(flag.Arg(0), ctx.Self.Id.String())
+ selfPath := filepath.Join(flag.Arg(0), ctx.SelfId.String())
isBad := false
var dir *os.File
var fis []os.FileInfo
}
var pktEnc nncp.PktEnc
_, err = xdr.Unmarshal(fd, &pktEnc)
- if err != nil || pktEnc.Magic != nncp.MagicNNCPEv1 {
+ if err != nil || pktEnc.Magic != nncp.MagicNNCPEv2 {
ctx.LogD("nncp-xfer", sds, "is not a packet")
fd.Close()
continue
if err != nil {
if os.IsNotExist(err) {
ctx.LogD("nncp-xfer", sds, "does not exist")
- if !*force {
+ if !*mkdir {
ctx.UnlockDir(dirLock)
continue
}
continue
}
}
- dstPath := filepath.Join(nodePath, ctx.Self.Id.String())
+ dstPath := filepath.Join(nodePath, ctx.SelfId.String())
sds["dir"] = dstPath
_, err = os.Stat(dstPath)
if err != nil {
job.Fd.Close()
continue
}
+ if _, err = os.Stat(filepath.Join(dstPath, pktName)); err == nil || !os.IsNotExist(err) {
+ ctx.LogD("nncp-xfer", sds, "already exists")
+ job.Fd.Close()
+ continue
+ }
+ if _, err = os.Stat(filepath.Join(dstPath, pktName+nncp.SeenPostfix)); err == nil || !os.IsNotExist(err) {
+ ctx.LogD("nncp-xfer", sds, "already exists")
+ job.Fd.Close()
+ continue
+ }
tmp, err := ioutil.TempFile(dstPath, "nncp-xfer")
if err != nil {
ctx.LogE("nncp-xfer", nncp.SdsAdd(sds, nncp.SDS{"err": err}), "mktemp")
isBad = true
continue
}
+ os.Remove(filepath.Join(dstPath, pktName+".part"))
delete(sds, "tmp")
ctx.LogI("nncp-xfer", nncp.SdsAdd(sds, nncp.SDS{
"size": strconv.FormatInt(copied, 10),