From 1ef7f1ab8cc340afdea5a62ea8bf2a1e5ec1268a Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 25 Jan 2022 20:42:29 +0300 Subject: [PATCH] Skip non-regular files in nncp-file --- doc/cmd/nncp-file.texi | 17 ++++++++++------- doc/news.ru.texi | 4 ++++ doc/news.texi | 4 ++++ src/tx.go | 4 ++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/doc/cmd/nncp-file.texi b/doc/cmd/nncp-file.texi index 0a80a4c..802e817 100644 --- a/doc/cmd/nncp-file.texi +++ b/doc/cmd/nncp-file.texi @@ -18,13 +18,16 @@ encrypted packet. If @file{SRC} equals to @file{-}, to data is read from @code{stdin}. If @file{SRC} points to directory, then -@url{https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_01, pax archive} -will be created on the fly with directory contents and destination -filename @file{.tar} appended. It @strong{won't} contain any entities -metainformation, but modification time with the names. UID/GID are set -to zero. Directories have 777 permissions, files have 666, for being -friendly with @command{umask}. Also each entity will have comment like -@verb{|Autogenerated by NNCP version X.Y.Z built with goXXX|}. +@url{https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_01, +pax archive} will be created on the fly with directory contents and +destination filename @file{.tar} appended. It @strong{won't} contain any +entities metainformation, except for modification time with the names. +UID/GID are set to zero. Directories have 777 permissions, files have +666, for being friendly with @command{umask}. Everything except +directories and regulars files is skipped. Also each entity will have +comment like @verb{|Autogenerated by NNCP version X.Y.Z built with goXXX|}. +For more precise metainformation and various file objects storage use +external @command{tar} command piped in. If @option{-chunked} is specified, then source file will be split @ref{Chunked, on chunks}. @option{INT} is the desired chunk size in diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 1a65bfa..61db762 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -15,6 +15,10 @@ У @command{nncp-call} команды появился @option{-mcd-wait} аргумент, позволяющий дожидаться multicast сообщения об адресе ноды. +@item +@command{nncp-file} команда пропускает всё что не является регулярным +файлом или директорией во время создания pax-архива. + @end itemize @node Релиз 8.3.0 diff --git a/doc/news.texi b/doc/news.texi index 6922d4b..fbb1d46 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -16,6 +16,10 @@ configuration options) are now regular expressions. By default @command{nncp-call} command has @option{-mcd-wait} option to wait for multicast packet about node's address. +@item +@command{nncp-file} command skips everything that is neither regular +file nor directory during pax-archive creation. + @end itemize @node Release 8_3_0 diff --git a/src/tx.go b/src/tx.go index b0377ed..77db592 100644 --- a/src/tx.go +++ b/src/tx.go @@ -330,11 +330,11 @@ func prepareTxFile(srcPath string) ( if err != nil { return err } - if info.IsDir() { + if info.Mode().IsDir() { // directory header, PAX record header+contents srcSize += TarBlockSize + 2*TarBlockSize dirs = append(dirs, einfo{path: path, modTime: info.ModTime()}) - } else { + } else if info.Mode().IsRegular() { // file header, PAX record header+contents, file content srcSize += TarBlockSize + 2*TarBlockSize + info.Size() if n := info.Size() % TarBlockSize; n != 0 { -- 2.44.0