Skip to content

Commit

Permalink
Merge pull request #6574 from 2403905/issue-6567
Browse files Browse the repository at this point in the history
Skip the error if the simulink is pointed to a directory
  • Loading branch information
2403905 authored Jun 21, 2023
2 parents 2c0fb99 + 5d5ef12 commit 9313be6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-dir-check.md
Original file line number Diff line number Diff line change
@@ -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
21 changes: 14 additions & 7 deletions services/notifications/pkg/email/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 9313be6

Please sign in to comment.