From 52599314b0832010d6d100d5d4d998d808016ab4 Mon Sep 17 00:00:00 2001 From: OopsMonk Date: Tue, 14 Nov 2017 15:21:26 +0800 Subject: [PATCH] fix symbolic links issue on Linux. (#281) Former-commit-id: 84a15d1ff70cbdcb91aaa7a40cb86604f036e349 [formerly 60e5a702fd98686193c5ee7bfb66698453de05ae] [formerly b863bd64cfc4e953c005f71ccc3fd936456b8a5e [formerly d269e239bfff9859f06fd0707578ad6c607ac9ba]] Former-commit-id: 24b6c15a5c3a54a866106eff843bea0d7401cf15 [formerly 6b6c3036a90776bb16d93a4b7e864e4f433f5531] Former-commit-id: 5b7aacabf2ceb1a5303fd303d5132bbdd711362f --- file.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/file.go b/file.go index 6c217b10..fa98fed1 100644 --- a/file.go +++ b/file.go @@ -133,6 +133,16 @@ func (i *File) GetListing(u *User, r *http.Request) error { continue } + if strings.HasPrefix(f.Mode().String(), "L") { + // It's a symbolic link + // The FileInfo from Readdir treats symbolic link as a file only. + info, err := os.Stat(f.Name()) + if err != nil { + return err + } + f = info + } + if f.IsDir() { name += "/" dirCount++