From 736d042497628241e86e78c01a195fd1585435cf Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Thu, 7 Nov 2019 15:51:40 +0300 Subject: [PATCH] Dotted duplicate filenames --- doc/news.ru.texi | 2 ++ doc/news.texi | 2 ++ src/cmd/nncp-reass/main.go | 2 +- src/toss.go | 2 +- src/toss_test.go | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 71a0b8e..a4bffeb 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -4,6 +4,8 @@ @node Релиз 4.2.0 @subsection Релиз 4.2.0 @itemize +@item Дубликаты имён файлов имеют суффикс @file{.CTR}, вместо + @file{CTR}, чтобы избежать возможных коллизий с @file{.nncp.chunkCTR}. @item По умолчанию файлы и директории создаются с 666/777 правами доступа, позволяя управлять ими @command{umask}-ом. @item Обновлены зависимости. diff --git a/doc/news.texi b/doc/news.texi index 7a8b9b9..440d103 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -6,6 +6,8 @@ See also this page @ref{Новости, on russian}. @node Release 4.2.0 @section Release 4.2.0 @itemize +@item Duplicate filenames have @file{.CTR} suffix, instead of + @file{CTR}, to avoid possible collisions with @file{.nncp.chunkCTR}. @item Files and directories are created with 666/777 permissions by default, allowing control with @command{umask}. @item Updated dependencies. diff --git a/src/cmd/nncp-reass/main.go b/src/cmd/nncp-reass/main.go index bc8f034..e1cb5b8 100644 --- a/src/cmd/nncp-reass/main.go +++ b/src/cmd/nncp-reass/main.go @@ -232,7 +232,7 @@ func process(ctx *nncp.Ctx, path string, keep, dryRun, stdout, dumpMeta bool) bo } log.Fatalln(err) } - dstPath = dstPathOrig + strconv.Itoa(dstPathCtr) + dstPath = dstPathOrig + "." + strconv.Itoa(dstPathCtr) dstPathCtr++ } if err = os.Rename(tmp.Name(), dstPath); err != nil { diff --git a/src/toss.go b/src/toss.go index 6422ac7..8166138 100644 --- a/src/toss.go +++ b/src/toss.go @@ -221,7 +221,7 @@ func (ctx *Ctx) Toss( isBad = true goto Closing } - dstPath = dstPathOrig + strconv.Itoa(dstPathCtr) + dstPath = dstPathOrig + "." + strconv.Itoa(dstPathCtr) dstPathCtr++ } if err = os.Rename(tmp.Name(), dstPath); err != nil { diff --git a/src/toss_test.go b/src/toss_test.go index 48149c4..a96f78b 100644 --- a/src/toss_test.go +++ b/src/toss_test.go @@ -285,7 +285,7 @@ func TestTossFileSameName(t *testing.T) { expected := make(map[string]struct{}) expected["samefile"] = struct{}{} for i := 0; i < files-1; i++ { - expected["samefile"+strconv.Itoa(i)] = struct{}{} + expected["samefile."+strconv.Itoa(i)] = struct{}{} } for _, filename := range dirFiles(incomingPath) { if _, exists := expected[filename]; !exists { -- 2.44.0