codeskyblue / gohttpserver

The best HTTP Static File Server, write with golang+vue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix Symbolic Links To Work as Directory

morb14 opened this issue · comments

commented

In httpstaticserver.go replace:

if info.IsDir() {
			name := deepPath(realPath, info.Name())
			lr.Name = name
			lr.Path = filepath.Join(filepath.Dir(path), name)
			lr.Type = "dir"
			lr.Size = s.historyDirSize(lr.Path)
		} else {
			lr.Type = "file"
			lr.Size = info.Size() // formatSize(info)
		}

with:

if info.Mode()&os.ModeSymlink != 0 {
	lr.Type = "dir"
	lr.Size = info.Size()
}  else if info.IsDir() {
	name := deepPath(realPath, info.Name())
	lr.Name = name
	lr.Path = filepath.Join(filepath.Dir(path), name)
	lr.Type = "dir"
	lr.Size = s.historyDirSize(lr.Path)
} else {
	lr.Type = "file"
	lr.Size = info.Size() // formatSize(info)
}