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)
|
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)
|
buildFeed(a)
|
||||||
go startWatcher(a)
|
go startWatcher(a)
|
||||||
return http.Serve(a.Listener, a.Router)
|
return http.Serve(a.Listener, a.Router)
|
||||||
|
|
|
@ -64,6 +64,7 @@ func DefaultConfig() *Config {
|
||||||
Server: &ServerConfig{
|
Server: &ServerConfig{
|
||||||
Host: "0.0.0.0",
|
Host: "0.0.0.0",
|
||||||
Port: 8000,
|
Port: 8000,
|
||||||
|
StorePath: "tube.db",
|
||||||
UploadPath: "uploads",
|
UploadPath: "uploads",
|
||||||
MaxUploadSize: 104857600,
|
MaxUploadSize: 104857600,
|
||||||
},
|
},
|
||||||
|
@ -74,7 +75,7 @@ func DefaultConfig() *Config {
|
||||||
Timeout: 300,
|
Timeout: 300,
|
||||||
},
|
},
|
||||||
Feed: &FeedConfig{
|
Feed: &FeedConfig{
|
||||||
ExternalURL: "http://localhost",
|
ExternalURL: "http://localhost:8000",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,10 @@ package media
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -39,6 +41,9 @@ func (lib *Library) AddPath(p *Path) error {
|
||||||
return errors.New("media: duplicate library prefix")
|
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
|
lib.Paths[p.Path] = p
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue