2022-04-08 17:44:40 +00:00
|
|
|
//go:build !no_stage
|
2020-09-11 21:51:45 +00:00
|
|
|
|
2019-03-20 00:21:49 +00:00
|
|
|
package static
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Stage(dataDir string) error {
|
|
|
|
for _, name := range AssetNames() {
|
|
|
|
content, err := Asset(name)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
p := filepath.Join(dataDir, name)
|
|
|
|
logrus.Info("Writing static file: ", p)
|
|
|
|
os.MkdirAll(filepath.Dir(p), 0700)
|
2022-10-08 00:36:57 +00:00
|
|
|
if err := os.WriteFile(p, content, 0600); err != nil {
|
2019-03-20 00:21:49 +00:00
|
|
|
return errors.Wrapf(err, "failed to write to %s", name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|