From 6d191a9636847b3c204487bf531089831999c9bb Mon Sep 17 00:00:00 2001 From: 4censord Date: Sat, 12 Oct 2024 23:55:00 +0200 Subject: [PATCH] Try fix crash --- server/filesystem/filesystem.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/filesystem/filesystem.go b/server/filesystem/filesystem.go index 41acde89..12afde31 100644 --- a/server/filesystem/filesystem.go +++ b/server/filesystem/filesystem.go @@ -530,6 +530,7 @@ func (fs *Filesystem) ListDirectory(p string) ([]Stat, error) { var m *mimetype.MIME d := "inode/directory" + if !f.IsDir() { cleanedp := filepath.Join(cleaned, f.Name()) if f.Mode()&os.ModeSymlink != 0 { @@ -542,11 +543,10 @@ func (fs *Filesystem) ListDirectory(p string) ([]Stat, error) { // @see https://github.com/pterodactyl/panel/issues/4059 if cleanedp != "" && f.Mode()&os.ModeNamedPipe == 0 { file, err := fs.manager.Open(filepath.Join(cleaned, f.Name())) - if err != nil { - // panic(fmt.Errorf("Error SFTP Open: %s", err)) - fmt.Println(err) + if err == nil { + m, _ = mimetype.DetectReader(file) } - m, _ = mimetype.DetectReader(file) + fmt.Println(err) } else { // Just pass this for an unknown type because the file could not safely be resolved within // the server data path.