Skip the error if the simulink is pointed to a directory
This commit is contained in:
@@ -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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"embed"
|
"embed"
|
||||||
|
"errors"
|
||||||
"html"
|
"html"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/owncloud/ocis/v2/services/notifications/pkg/channels"
|
"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) {
|
func read(entries []fs.DirEntry, fsys fs.FS) (map[string][]byte, error) {
|
||||||
list := make(map[string][]byte)
|
list := make(map[string][]byte)
|
||||||
for _, e := range entries {
|
for _, e := range entries {
|
||||||
if !e.IsDir() {
|
if e.IsDir() {
|
||||||
file, err := fs.ReadFile(fsys, filepath.Join(imgDir, e.Name()))
|
continue
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
file, err := fs.ReadFile(fsys, filepath.Join(imgDir, e.Name()))
|
||||||
}
|
if err != nil {
|
||||||
if !validateMime(file) {
|
// skip if the symbolic is a directory
|
||||||
|
if errors.Is(err, syscall.EISDIR) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
list[e.Name()] = file
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if !validateMime(file) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
list[e.Name()] = file
|
||||||
}
|
}
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user