Fix asset provisioning to strip embedded share/radiantwave root

This commit is contained in:
NeilClack
2026-08-03 02:40:51 -05:00
parent 11b25227d7
commit b54dbca2d5
3 changed files with 55 additions and 1 deletions
+19
View File
@@ -11,6 +11,25 @@ import (
"path/filepath"
)
// embeddedRoot is the directory in the source tree (and therefore in the
// embedded FS) where the bundled assets live. It mirrors the nix store
// layout, but consumers expect the assets directly under the assets dir,
// so this root is stripped during provisioning.
const embeddedRoot = "share/radiantwave"
// ProvisionAssets provisions the bundled static assets (fonts, shaders, and
// terms-of-service pages) into destDir, stripping the embedded
// share/radiantwave root so the files land directly in destDir rather than
// in a nested share/radiantwave/ subdirectory. Existing files are
// overwritten so the deployed assets always match the running binary.
func ProvisionAssets(bundled fs.FS, destDir string) error {
root, err := fs.Sub(bundled, embeddedRoot)
if err != nil {
return fmt.Errorf("bundled assets missing %s root: %w", embeddedRoot, err)
}
return Provision(root, destDir)
}
// Provision copies every file from the embedded filesystem into destDir,
// preserving the relative directory structure. Existing files are
// overwritten so the deployed assets always match the running binary.