]> Cypherpunks.ru repositories - nncp.git/commitdiff
Check disk space when sending
authorSergey Matveev <stargrave@stargrave.org>
Fri, 22 Nov 2019 19:40:43 +0000 (22:40 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 24 Nov 2019 15:08:55 +0000 (18:08 +0300)
doc/news.ru.texi
doc/news.texi
src/tx.go

index e85b0b8e2a44e04ac5c43950f5a1843ffd0c6789..a7508f448cf92738f8d6b88e0cdc0f36578620d5 100644 (file)
@@ -9,6 +9,10 @@
 @command{nncp-file} может отправлять директории, автоматически на лету
 создавая pax архив.
 
+@item
+Во время создания исходящих сообщений проверяется наличие свободного
+места на файловой системе.
+
 @end itemize
 
 @node Релиз 5.0.0
index e29cf17e064cf22573967724de7abcb01d48a70b..2617f96130294d0677c0f218b6d90ac74d50b2bf 100644 (file)
@@ -11,6 +11,9 @@ See also this page @ref{Новости, on russian}.
 @command{nncp-file} can send directories, automatically creating pax
 archive on the fly.
 
+@item
+Free disk space is checked during outbound packets creation.
+
 @end itemize
 
 @node Release 5.0.0
index 88d4e9af4b4dfd9fe3f570fbca88b6d65296a951..4b7cb347cc992a3f4f4e58152671d61581bbe275 100644 (file)
--- a/src/tx.go
+++ b/src/tx.go
@@ -50,10 +50,6 @@ func (ctx *Ctx) Tx(
        size, minSize int64,
        src io.Reader,
 ) (*Node, error) {
-       tmp, err := ctx.NewTmpFileWHash()
-       if err != nil {
-               return nil, err
-       }
        hops := make([]*Node, 0, 1+len(node.Via))
        hops = append(hops, node)
        lastNode := node
@@ -69,6 +65,14 @@ func (ctx *Ctx) Tx(
        if padSize < 0 {
                padSize = 0
        }
+       if !ctx.IsEnoughSpace(size + padSize) {
+               return nil, errors.New("is not enough space")
+       }
+       tmp, err := ctx.NewTmpFileWHash()
+       if err != nil {
+               return nil, err
+       }
+
        errs := make(chan error)
        curSize := size
        pipeR, pipeW := io.Pipe()
@@ -559,6 +563,11 @@ func (ctx *Ctx) TxTrns(node *Node, nice uint8, size int64, src io.Reader) error
                "size": strconv.FormatInt(size, 10),
        }
        ctx.LogD("tx", sds, "taken")
+       if !ctx.IsEnoughSpace(size) {
+               err := errors.New("is not enough space")
+               ctx.LogE("tx", sds, err.Error())
+               return err
+       }
        tmp, err := ctx.NewTmpFileWHash()
        if err != nil {
                return err