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: build_frontend:
NODE_ENV=production npm run build 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: build_backend:
CGO_ENABLED=1 go build --tags "fts5" -o dist/filestash cmd/main.go 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 continue
} }
curPath := filePath + cfg.FileExt curPath := filePath + cfg.FileExt
file, err := WWWEmbed.Open("static/www" + curPath) var (
if env := os.Getenv("DEBUG"); env == "true" { file fs.File
file, err = WWWDir.Open("server/ctrl/static/www" + curPath) err error
} else if os.Getenv("CANARY") != "" { )
file, err = WWWDir.Open("public" + curPath) 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 { if err != nil {
continue continue