fix (#187): handle simlinks

This commit is contained in:
Mickael Kerjean 2019-08-13 16:02:00 +01:00
parent 995d6c11f0
commit 4814175f00
2 changed files with 8 additions and 5 deletions

View file

@ -37,6 +37,9 @@ func (f File) Size() int64 {
return f.FSize
}
func (f File) Mode() os.FileMode {
if f.IsDir() {
return os.ModeDir
}
return 0
}
func (f File) ModTime() time.Time {

View file

@ -69,12 +69,12 @@ func FileLs(ctx App, res http.ResponseWriter, req *http.Request) {
Name: name,
Size: entries[i].Size(),
Time: modTime,
Type: func(isDir bool) string {
if isDir == true {
return "directory"
Type: func(mode os.FileMode) string {
if mode.IsRegular() {
return "file"
}
return "file"
}(entries[i].IsDir()),
return "directory"
}(entries[i].Mode()),
}
}