Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip the error if the simulink is pointed to a directory #6574

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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