feature (canary): toggle for canary release

This commit is contained in:
MickaelK 2024-06-13 22:32:04 +10:00
parent 87c41adfe7
commit f0895fc483
2 changed files with 19 additions and 5 deletions

View file

@ -9,6 +9,9 @@ build_init:
build_frontend:
NODE_ENV=production npm run build
mkdir -p ./server/ctrl/static/www/canary/
cp -R ./public/assets ./server/ctrl/static/www/canary/
cp -R ./public/*.html ./server/ctrl/static/www/canary/
build_backend:
CGO_ENABLED=1 go build --tags "fts5" -o dist/filestash cmd/main.go

View file

@ -98,11 +98,22 @@ func LegacyServeFile(res http.ResponseWriter, req *http.Request, filePath string
continue
}
curPath := filePath + cfg.FileExt
file, err := WWWEmbed.Open("static/www" + curPath)
if env := os.Getenv("DEBUG"); env == "true" {
file, err = WWWDir.Open("server/ctrl/static/www" + curPath)
} else if os.Getenv("CANARY") != "" {
file, err = WWWDir.Open("public" + curPath)
var (
file fs.File
err error
)
if os.Getenv("CANARY") == "true" { // TODO: remove legacy option
if env := os.Getenv("DEBUG"); env == "true" {
file, err = WWWDir.Open("public" + curPath)
} else {
file, err = WWWEmbed.Open("static/www/canary" + curPath)
}
} else {
if env := os.Getenv("DEBUG"); env == "true" {
file, err = WWWDir.Open("server/ctrl/static/www" + curPath)
} else {
file, err = WWWEmbed.Open("static/www" + curPath)
}
}
if err != nil {
continue