cmd/dendrite-media-api-server: Make base path absolute

This commit is contained in:
Robert Swain 2017-05-18 17:25:12 +02:00
parent f5422787a1
commit 995e1f2c99

View file

@ -17,6 +17,7 @@ package main
import ( import (
"net/http" "net/http"
"os" "os"
"path/filepath"
"strconv" "strconv"
"github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/common"
@ -47,6 +48,10 @@ func main() {
if basePath == "" { if basePath == "" {
log.Panic("No BASE_PATH environment variable found.") log.Panic("No BASE_PATH environment variable found.")
} }
absBasePath, err := filepath.Abs(basePath)
if err != nil {
log.Panicf("BASE_PATH is invalid (must be able to make absolute): %v\n", err)
}
if serverName == "" { if serverName == "" {
serverName = "localhost" serverName = "localhost"
@ -59,7 +64,7 @@ func main() {
cfg := &config.MediaAPI{ cfg := &config.MediaAPI{
ServerName: gomatrixserverlib.ServerName(serverName), ServerName: gomatrixserverlib.ServerName(serverName),
BasePath: types.Path(basePath), BasePath: types.Path(absBasePath),
MaxFileSizeBytes: types.ContentLength(maxFileSizeBytes), MaxFileSizeBytes: types.ContentLength(maxFileSizeBytes),
DataSource: dataSource, DataSource: dataSource,
} }