EventManager: check the parent directory before creating a zip

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2023-04-03 18:53:13 +02:00
parent aefa7f77c2
commit 74f05e5305
5 changed files with 8 additions and 21 deletions

View File

@@ -5429,22 +5429,6 @@ func TestEventActionCompressErrors(t *testing.T) {
err = f.Close()
assert.Error(t, err)
}
// try to write to a missing directory
action1.Options.FsConfig.Compress.Name = "/subdir/missing/path/file.zip"
_, _, err = httpdtest.UpdateEventAction(action1, http.StatusOK)
assert.NoError(t, err)
conn, client, err = getSftpClient(user)
if assert.NoError(t, err) {
defer conn.Close()
defer client.Close()
f, err := client.Create(testFileName)
assert.NoError(t, err)
_, err = f.Write(testFileContent)
assert.NoError(t, err)
err = f.Close()
assert.Error(t, err)
}
_, err = httpdtest.RemoveEventRule(rule1, http.StatusOK)
assert.NoError(t, err)
@@ -5473,7 +5457,7 @@ func TestEventActionEmailAttachments(t *testing.T) {
FsConfig: dataprovider.EventActionFilesystemConfig{
Type: dataprovider.FilesystemActionCompress,
Compress: dataprovider.EventActionFsCompress{
Name: "/{{VirtualPath}}.zip",
Name: "/archive/{{VirtualPath}}.zip",
Paths: []string{"/{{VirtualPath}}"},
},
},
@@ -5489,7 +5473,7 @@ func TestEventActionEmailAttachments(t *testing.T) {
Recipients: []string{"test@example.com"},
Subject: `"{{Event}}" from "{{Name}}"`,
Body: "Fs path {{FsPath}}, size: {{FileSize}}, protocol: {{Protocol}}, IP: {{IP}}",
Attachments: []string{"/{{VirtualPath}}.zip"},
Attachments: []string{"/archive/{{VirtualPath}}.zip"},
},
},
}