Fix default server config and ensure upload and video paths exist

This commit is contained in:
James Mills 2020-03-29 19:02:52 +10:00
parent a22a2ae031
commit 980a3edf63
No known key found for this signature in database
GPG key ID: AC4C014F1440EBD6
3 changed files with 13 additions and 1 deletions

View file

@ -162,6 +162,12 @@ func (a *App) Run() error {
}
a.Watcher.Add(p.Path)
}
if err := os.MkdirAll(a.Config.Server.UploadPath, 0755); err != nil {
return fmt.Errorf(
"error creating upload path %s: %w",
a.Config.Server.UploadPath, err,
)
}
buildFeed(a)
go startWatcher(a)
return http.Serve(a.Listener, a.Router)

View file

@ -64,6 +64,7 @@ func DefaultConfig() *Config {
Server: &ServerConfig{
Host: "0.0.0.0",
Port: 8000,
StorePath: "tube.db",
UploadPath: "uploads",
MaxUploadSize: 104857600,
},
@ -74,7 +75,7 @@ func DefaultConfig() *Config {
Timeout: 300,
},
Feed: &FeedConfig{
ExternalURL: "http://localhost",
ExternalURL: "http://localhost:8000",
},
}
}

View file

@ -2,8 +2,10 @@ package media
import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"path"
"path/filepath"
"strings"
@ -39,6 +41,9 @@ func (lib *Library) AddPath(p *Path) error {
return errors.New("media: duplicate library prefix")
}
}
if err := os.MkdirAll(p.Path, 07550); err != nil {
return fmt.Errorf("error creating library path %s: %w", p.Path, err)
}
lib.Paths[p.Path] = p
return nil
}