Default upstream path if not specified

This commit is contained in:
Ben Johnson
2022-04-03 09:09:50 -06:00
parent 6aba416656
commit 46888530b2

View File

@@ -309,10 +309,12 @@ func NewDBFromConfigWithPath(dbc *DBConfig, path string) (*litestream.DB, error)
// Attach upstream HTTP client if specified. // Attach upstream HTTP client if specified.
if upstreamURL := dbc.Upstream.URL; upstreamURL != "" { if upstreamURL := dbc.Upstream.URL; upstreamURL != "" {
if dbc.Upstream.Path == "" { // Use local database path if upstream path is not specified.
return nil, fmt.Errorf("upstream path required") upstreamPath := dbc.Upstream.Path
if upstreamPath == "" {
upstreamPath = db.Path()
} }
db.StreamClient = http.NewClient(upstreamURL, dbc.Upstream.Path) db.StreamClient = http.NewClient(upstreamURL, upstreamPath)
} }
// Override default database settings if specified in configuration. // Override default database settings if specified in configuration.