mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-15 08:41:19 -06:00
Skip the error if the simulink is pointed to a directory
This commit is contained in:
6
changelog/unreleased/fix-dir-check.md
Normal file
6
changelog/unreleased/fix-dir-check.md
Normal 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
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user