Fix default server config and ensure upload and video paths exist
This commit is contained in:
parent
a22a2ae031
commit
980a3edf63
3 changed files with 13 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue