Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Considering HOME environment variable in fileserver (fixes #309) #310

Merged
merged 1 commit into from
Nov 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion selenium/base/fileserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,24 @@ import (
)

func main() {
log.Fatal(http.ListenAndServe(":8080", mux("/home/selenium/Downloads")))
dir, err := downloadsDir()
if err != nil {
log.Fatal(err)
}
log.Fatal(http.ListenAndServe(":8080", mux(dir)))
}

func downloadsDir() (string, error) {
homeDir := os.Getenv("HOME")
if homeDir == "" {
homeDir = "/home/selenium"
}
dir := filepath.Join(homeDir, "Downloads")
err := os.MkdirAll(dir, 0755)
if err != nil {
return "", fmt.Errorf("failed to create downloads dir: %v", err)
}
return dir, nil
}

const jsonParam = "json"
Expand Down