Skip to content

Commit

Permalink
try fix the crash
Browse files Browse the repository at this point in the history
  • Loading branch information
4censord committed Oct 12, 2024
1 parent 03d6ca0 commit 85fe26d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- develop
pull_request:
branches:
- develop
release:
types:
- published
Expand Down
12 changes: 8 additions & 4 deletions server/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ func (fs *Filesystem) ListDirectory(p string) ([]Stat, error) {
go func(idx int, f os.FileInfo) {
defer wg.Done()

var m *mimetype.MIME
var mime *mimetype.MIME
d := "inode/directory"
if !f.IsDir() {
cleanedp := filepath.Join(cleaned, f.Name())
Expand All @@ -546,7 +546,11 @@ func (fs *Filesystem) ListDirectory(p string) ([]Stat, error) {
// panic(fmt.Errorf("Error SFTP Open: %s", err))
fmt.Println(err)
}
m, _ = mimetype.DetectReader(file)
mime, err = mimetype.DetectReader(file)
if err != nil {
fmt.Println(err)
d = "application/octet-stream"
}
} else {
// Just pass this for an unknown type because the file could not safely be resolved within
// the server data path.
Expand All @@ -555,8 +559,8 @@ func (fs *Filesystem) ListDirectory(p string) ([]Stat, error) {
}

st := Stat{FileInfo: f, Mimetype: d}
if m != nil {
st.Mimetype = m.String()
if mime != nil {
st.Mimetype = mime.String()
}
out[idx] = st
}(i, file)
Expand Down

0 comments on commit 85fe26d

Please sign in to comment.