]> Cypherpunks.ru repositories - nncp.git/commitdiff
nncp-xfer compares the checksum
authorSergey Matveev <stargrave@stargrave.org>
Wed, 2 Mar 2022 09:44:24 +0000 (12:44 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 2 Mar 2022 09:53:39 +0000 (12:53 +0300)
doc/news.ru.texi
doc/news.texi
src/cmd/nncp-xfer/main.go

index 76ebe57484300dc7bddccbe57c05cbd7f626e9e3..9b19a52a8da16372f9cbf256510dc0817b4d80fb 100644 (file)
@@ -5,6 +5,10 @@
 @subsection Релиз 8.6.0
 @itemize
 
 @subsection Релиз 8.6.0
 @itemize
 
+@item
+@command{nncp-xfer} проверяет сходится ли контрольная сумма
+скопированного локально пакета и исходного.
+
 @item
 Появилась возможность отключения @code{fsync} операции
 @env{$NNCPNOSYNC=1} переменной окружения.
 @item
 Появилась возможность отключения @code{fsync} операции
 @env{$NNCPNOSYNC=1} переменной окружения.
index 93edf29690d745168e9a56e4148dd3a7075241a0..03c719710ca773210f666dfb7070769d9bcfe45e 100644 (file)
@@ -8,6 +8,10 @@ See also this page @ref{Новости, on russian}.
 @section Release 8.6.0
 @itemize
 
 @section Release 8.6.0
 @itemize
 
+@item
+@command{nncp-xfer} checks if locally copied packet's checksum differs
+from the source's one.
+
 @item
 Ability to turn @code{fsync} operation off using @env{$NNCPNOSYNC=1}
 environment variable.
 @item
 Ability to turn @code{fsync} operation off using @env{$NNCPNOSYNC=1}
 environment variable.
index a349ea27d910143e11e255d03a43e1a73888fac9..a1ef5fa5d51c438179b33450f7876352d62d5242 100644 (file)
@@ -284,7 +284,7 @@ func main() {
                                        w.CloseWithError(err)
                                }
                        }()
                                        w.CloseWithError(err)
                                }
                        }()
-                       if _, err = nncp.CopyProgressed(
+                       _, err = nncp.CopyProgressed(
                                tmp.W, r, "Rx",
                                append(
                                        les,
                                tmp.W, r, "Rx",
                                append(
                                        les,
@@ -292,13 +292,24 @@ func main() {
                                        nncp.LE{K: "FullSize", V: fiInt.Size()},
                                ),
                                ctx.ShowPrgrs,
                                        nncp.LE{K: "FullSize", V: fiInt.Size()},
                                ),
                                ctx.ShowPrgrs,
-                       ); err != nil {
+                       )
+                       fd.Close()
+                       if err != nil {
                                ctx.LogE("xfer-rx", les, err, logMsg)
                                ctx.LogE("xfer-rx", les, err, logMsg)
+                               tmp.Cancel()
                                isBad = true
                                isBad = true
+                               continue
                        }
                        }
-                       fd.Close()
-                       if isBad {
+                       if err = tmp.W.Flush(); err != nil {
+                               ctx.LogE("xfer-rx", les, err, logMsg)
+                               tmp.Cancel()
+                               isBad = true
+                               continue
+                       }
+                       if tmp.Checksum() != fiInt.Name() {
+                               ctx.LogE("xfer-rx", les, errors.New("checksum mismatch"), logMsg)
                                tmp.Cancel()
                                tmp.Cancel()
+                               isBad = true
                                continue
                        }
                        if err = tmp.Commit(filepath.Join(
                                continue
                        }
                        if err = tmp.Commit(filepath.Join(