]> Cypherpunks.ru repositories - nncp.git/commitdiff
Small chunked files are sent as an ordinary ones
authorSergey Matveev <stargrave@stargrave.org>
Wed, 14 Feb 2018 21:09:34 +0000 (00:09 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 15 Feb 2018 09:13:32 +0000 (12:13 +0300)
doc/news.ru.texi
doc/news.texi
src/cypherpunks.ru/nncp/tx.go

index ec168faf3c5374c161166e12399acc262ea1dbda..fd37894b61382d35c11bb9bf2ec276eacf312011 100644 (file)
@@ -8,6 +8,9 @@
 Возможность переопределить @option{via} опцию конфигурации для целевого
 узла через @option{-via} опцию командной строки для следующих команд:
 @command{nncp-file}, @command{nncp-freq}, @command{nncp-mail}.
+@item
+Chunked файлы, меньшего размера чем указанный chunk, отправляются просто
+в виде одного файла.
 @end itemize
 
 @node Релиз 2.0
index d2dbd6148436c8e12be1b433340932097d9563e0..475583e86e66da5eea9fd46aeb8c1d21aaef1daf 100644 (file)
@@ -10,6 +10,9 @@ See also this page @ref{Новости, on russian}.
 Ability to override @option{via} configuration option for destination
 node via @option{-via} command line option for following commands:
 @command{nncp-file}, @command{nncp-freq}, @command{nncp-mail}.
+@item
+Chunked files, having size less than specified chunk size, will be sent
+as an ordinary single file.
 @end itemize
 
 @node Release 2.0
index aeb1748e33f3c6592a901f7552260d6514b0d7b9..0569ccef2860d589e092e9529c49f247f022cb6f 100644 (file)
@@ -211,6 +211,35 @@ func (ctx *Ctx) TxFileChunked(node *Node, nice uint8, srcPath, dstPath string, m
                return err
        }
 
+       if fileSize <= chunkSize {
+               pkt, err := NewPkt(PktTypeFile, dstPath)
+               if err != nil {
+                       return err
+               }
+               _, err = ctx.Tx(node, pkt, nice, fileSize, minSize, reader)
+               if err == nil {
+                       ctx.LogI("tx", SDS{
+                               "type": "file",
+                               "node": node.Id,
+                               "nice": strconv.Itoa(int(nice)),
+                               "src":  srcPath,
+                               "dst":  dstPath,
+                               "size": strconv.FormatInt(fileSize, 10),
+                       }, "sent")
+               } else {
+                       ctx.LogE("tx", SDS{
+                               "type": "file",
+                               "node": node.Id,
+                               "nice": strconv.Itoa(int(nice)),
+                               "src":  srcPath,
+                               "dst":  dstPath,
+                               "size": strconv.FormatInt(fileSize, 10),
+                               "err":  err,
+                       }, "sent")
+               }
+               return err
+       }
+
        leftSize := fileSize
        metaPkt := ChunkedMeta{
                Magic:     MagicNNCPMv1,