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")
log.Fatalln("-rx and -tx can not be set simultaneously")
}
- cfgRaw, err := ioutil.ReadFile(*cfgPath)
+ cfgRaw, err := ioutil.ReadFile(nncp.CfgPathFromEnv(cfgPath))
if err != nil {
log.Fatalln("Can not read config:", err)
}
}
}
- 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
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 {
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),