X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Ftx.go;h=5c5c446171122b62620a1b246b7477e2fa16d5ff;hb=d529dd1ff29a8dc0a2d22a75e044e9162a0afb78;hp=4b7cb347cc992a3f4f4e58152671d61581bbe275;hpb=09afeef5b0f3a3a7305249dd3e8d8ea76fd69b04;p=nncp.git diff --git a/src/tx.go b/src/tx.go index 4b7cb34..5c5c446 100644 --- a/src/tx.go +++ b/src/tx.go @@ -39,6 +39,8 @@ import ( ) const ( + MaxFileSize = 1 << 62 + TarBlockSize = 512 TarExt = ".tar" ) @@ -279,58 +281,12 @@ func prepareTxFile(srcPath string) (reader io.Reader, closer io.Closer, fileSize 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 == "" {