diff --git a/changelog/unreleased/fix-dir-check.md b/changelog/unreleased/fix-dir-check.md new file mode 100644 index 0000000000..2dcbb0cc0b --- /dev/null +++ b/changelog/unreleased/fix-dir-check.md @@ -0,0 +1,6 @@ +Enhancement: Skip if the simulink is a directory + +Skip the error if the simulink is pointed to a directory + +https://github.com/owncloud/ocis/pull/6574 +https://github.com/owncloud/ocis/issues/6567 diff --git a/services/notifications/pkg/email/email.go b/services/notifications/pkg/email/email.go index 733f86388d..03a37b4992 100644 --- a/services/notifications/pkg/email/email.go +++ b/services/notifications/pkg/email/email.go @@ -6,12 +6,14 @@ package email import ( "bytes" "embed" + "errors" "html" "html/template" "io/fs" "os" "path/filepath" "strings" + "syscall" "github.com/owncloud/ocis/v2/services/notifications/pkg/channels" ) @@ -104,16 +106,21 @@ func readImages(emailTemplatePath string) (map[string][]byte, error) { func read(entries []fs.DirEntry, fsys fs.FS) (map[string][]byte, error) { list := make(map[string][]byte) for _, e := range entries { - if !e.IsDir() { - file, err := fs.ReadFile(fsys, filepath.Join(imgDir, e.Name())) - if err != nil { - return nil, err - } - if !validateMime(file) { + if e.IsDir() { + continue + } + file, err := fs.ReadFile(fsys, filepath.Join(imgDir, e.Name())) + if err != nil { + // skip if the symbolic is a directory + if errors.Is(err, syscall.EISDIR) { continue } - list[e.Name()] = file + return nil, err } + if !validateMime(file) { + continue + } + list[e.Name()] = file } return list, nil }