func (nodeOur *NodeOur) Their() *Node {
return &Node{
- Name: "self",
- Id: nodeOur.Id,
- ExchPub: nodeOur.ExchPub,
- SignPub: nodeOur.SignPub,
+ Name: "self",
+ Id: nodeOur.Id,
+ ExchPub: nodeOur.ExchPub,
+ SignPub: nodeOur.SignPub,
+ FreqChunked: MaxFileSize,
}
}
goto Closing
}
if !dryRun {
- if sender.FreqChunked == 0 {
- err = ctx.TxFile(
- sender,
- pkt.Nice,
- filepath.Join(*freqPath, src),
- dst,
- sender.FreqMinSize,
- )
- } else {
- err = ctx.TxFileChunked(
- sender,
- pkt.Nice,
- filepath.Join(*freqPath, src),
- dst,
- sender.FreqMinSize,
- sender.FreqChunked,
- )
- }
+ err = ctx.TxFile(
+ sender,
+ pkt.Nice,
+ filepath.Join(*freqPath, src),
+ dst,
+ sender.FreqChunked,
+ sender.FreqMinSize,
+ )
if err != nil {
ctx.LogE("rx", SdsAdd(sds, SDS{"err": err}), "tx file")
isBad = true
)
const (
+ MaxFileSize = 1 << 62
+
TarBlockSize = 512
TarExt = ".tar"
)
return
}
-func (ctx *Ctx) TxFile(node *Node, nice uint8, srcPath, dstPath string, minSize int64) error {
- dstPathSpecified := false
- if dstPath == "" {
- if srcPath == "-" {
- return errors.New("Must provide destination filename")
- }
- dstPath = filepath.Base(srcPath)
- } else {
- dstPathSpecified = true
- }
- dstPath = filepath.Clean(dstPath)
- if filepath.IsAbs(dstPath) {
- return errors.New("Relative destination path required")
- }
- reader, closer, fileSize, archived, err := prepareTxFile(srcPath)
- if closer != nil {
- defer closer.Close()
- }
- if err != nil {
- return err
- }
- if archived && !dstPathSpecified {
- dstPath += TarExt
- }
- pkt, err := NewPkt(PktTypeFile, nice, []byte(dstPath))
- if err != nil {
- return err
- }
- _, err = ctx.Tx(node, pkt, nice, fileSize, minSize, reader)
- sds := SDS{
- "type": "file",
- "node": node.Id,
- "nice": strconv.Itoa(int(nice)),
- "src": srcPath,
- "dst": dstPath,
- "size": strconv.FormatInt(fileSize, 10),
- }
- if err == nil {
- ctx.LogI("tx", sds, "sent")
- } else {
- sds["err"] = err
- ctx.LogE("tx", sds, "sent")
- }
- return err
-}
-
-func (ctx *Ctx) TxFileChunked(
+func (ctx *Ctx) TxFile(
node *Node,
nice uint8,
srcPath, dstPath string,
- minSize int64,
chunkSize int64,
+ minSize int64,
) error {
dstPathSpecified := false
if dstPath == "" {