Skip the error if the simulink is pointed to a directory

This commit is contained in:
Roman Perekhod
2023-06-21 15:14:18 +02:00
parent 2c0fb9910e
commit 5d5ef12e7c
2 changed files with 20 additions and 7 deletions

View File

@@ -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

View File

@@ -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
}