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 (
"net/http"
"os"
"path/filepath"
"strconv"
"github.com/matrix-org/dendrite/common"
@ -47,6 +48,10 @@ func main() {
if basePath == "" {
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 == "" {
serverName = "localhost"
@ -59,7 +64,7 @@ func main() {
cfg := &config.MediaAPI{
ServerName: gomatrixserverlib.ServerName(serverName),
BasePath: types.Path(basePath),
BasePath: types.Path(absBasePath),
MaxFileSizeBytes: types.ContentLength(maxFileSizeBytes),
DataSource: dataSource,
}