Shiz innit
This commit is contained in:
parent
3ad3666002
commit
2c0a3c7d80
8 changed files with 25 additions and 14 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pelletier/go-toml/v2"
|
||||
|
|
@ -19,6 +20,12 @@ type Asset struct {
|
|||
func (asset *Asset) FetchIfNotExists(staticPath string) {
|
||||
destPath := filepath.Join(staticPath, asset.Path)
|
||||
|
||||
err := os.MkdirAll(path.Dir(destPath), os.ModeDir|0777)
|
||||
if err != nil {
|
||||
log.Printf("Couldn't create parent dirs of %s\n", destPath)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
out, err := os.OpenFile(
|
||||
destPath,
|
||||
os.O_WRONLY|os.O_CREATE|os.O_EXCL,
|
||||
|
|
@ -75,6 +82,8 @@ func LoadConfig(path string) {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
os.Mkdir(Conf.Static.Dir, os.FileMode(750))
|
||||
|
||||
for _, asset := range Conf.Static.Assets {
|
||||
asset.FetchIfNotExists(Conf.Static.Dir)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue