From aa1e73326f3ee4ce2c1de7231197a7562239ec95 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Wed, 12 Oct 2022 11:37:31 +0200 Subject: [PATCH] FTPD: fix APPE to new files Signed-off-by: Nicola Murino --- go.mod | 2 +- go.sum | 4 ++-- internal/ftpd/ftpd_test.go | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e1b4655d..c9884de9 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/cockroachdb/cockroach-go/v2 v2.2.16 github.com/coreos/go-oidc/v3 v3.4.0 github.com/eikenb/pipeat v0.0.0-20210730190139-06b3e6902001 - github.com/fclairamb/ftpserverlib v0.20.0 + github.com/fclairamb/ftpserverlib v0.20.1-0.20221012093027-95be4ae0c9a6 github.com/fclairamb/go-log v0.4.1 github.com/go-acme/lego/v4 v4.9.0 github.com/go-chi/chi/v5 v5.0.8-0.20220512131524-9e71a0d4b3d6 diff --git a/go.sum b/go.sum index 65a599f6..7db678e7 100644 --- a/go.sum +++ b/go.sum @@ -577,8 +577,8 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fclairamb/ftpserverlib v0.20.0 h1:9NjQPxo3T0XQCyzSXZJ0XBH4mk4Qv4Lpw3GNVabvnpU= -github.com/fclairamb/ftpserverlib v0.20.0/go.mod h1:7pR5Ckeygw3T006z1ND6HYSbJz+fTvkFAXlF6snW4yI= +github.com/fclairamb/ftpserverlib v0.20.1-0.20221012093027-95be4ae0c9a6 h1:rnwZJ/8Y6yX9ZxsWy+9kyvUWPgc66HGr2Kyumb4Uvs0= +github.com/fclairamb/ftpserverlib v0.20.1-0.20221012093027-95be4ae0c9a6/go.mod h1:VN4BIwbu4XeC2cyPFtuVDwXtpoDtsr+5+doTuOfdXKY= github.com/fclairamb/go-log v0.4.1 h1:rLtdSG9x2pK41AIAnE8WYpl05xBJfw1ZyYxZaXFcBsM= github.com/fclairamb/go-log v0.4.1/go.mod h1:sw1KvnkZ4wKCYkvy4SL3qVZcJSWFP8Ure4pM3z+KNn4= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= diff --git a/internal/ftpd/ftpd_test.go b/internal/ftpd/ftpd_test.go index 6cc2307a..0e94fe2d 100644 --- a/internal/ftpd/ftpd_test.go +++ b/internal/ftpd/ftpd_test.go @@ -2062,6 +2062,23 @@ func TestResume(t *testing.T) { expected := append(data, data...) assert.Equal(t, expected, readed) } + // append to a new file + srcFile, err = os.Open(testFilePath) + if assert.NoError(t, err) { + newFileName := testFileName + "_new" + err = client.Append(newFileName, srcFile) + assert.NoError(t, err) + err = srcFile.Close() + assert.NoError(t, err) + size, err := client.FileSize(newFileName) + assert.NoError(t, err) + assert.Equal(t, int64(len(data)), size) + err = ftpDownloadFile(newFileName, localDownloadPath, int64(len(data)), client, 0) + assert.NoError(t, err) + readed, err = os.ReadFile(localDownloadPath) + assert.NoError(t, err) + assert.Equal(t, data, readed) + } err = client.Quit() assert.NoError(t, err) err = os.Remove(testFilePath)