minor bug fixes during serving of gophermap / dir listings

Signed-off-by: kim (grufwub) <grufwub@gmail.com>
This commit is contained in:
kim (grufwub) 2020-04-15 10:52:03 +01:00
parent 4fee274ed5
commit 2c9d68c2ac
2 changed files with 4 additions and 6 deletions

View File

@ -77,7 +77,6 @@ func bufferedRead(path string) ([]byte, *GophorError) {
/* Open file */
fd, err := os.Open(path)
if err != nil {
logSystemError("failed to open %s: %s\n", path, err.Error())
return nil, &GophorError{ FileOpenErr, err }
}
defer fd.Close()
@ -98,7 +97,6 @@ func bufferedRead(path string) ([]byte, *GophorError) {
break
}
logSystemError("failed to read %s: %s\n", path, err.Error())
return nil, &GophorError{ FileReadErr, err }
}

View File

@ -182,8 +182,8 @@ func (worker *Worker) Respond(data []byte) *GophorError {
/* Directory */
case Dir:
/* First try to serve gopher map */
requestPath = path.Join(requestPath, "/"+GophermapFileStr)
fileContents, gophorErr := GophermapCache.Fetch(requestPath)
gophermapPath := path.Join(requestPath, "/"+GophermapFileStr)
fileContents, gophorErr := GophermapCache.Fetch(gophermapPath)
if gophorErr != nil {
/* Get directory listing instead */
fileContents, gophorErr = listDir(requestPath, map[string]bool{})
@ -201,7 +201,7 @@ func (worker *Worker) Respond(data []byte) *GophorError {
} else {
/* Successfully loaded gophermap, add fileContents to response */
response = append(response, fileContents...)
worker.Log("server gophermap: %s\n", requestPath)
worker.Log("serve gophermap: %s\n", gophermapPath)
}
/* Regular file */