static
This commit is contained in:
parent
9d5a33e743
commit
53a5e2e45a
3 changed files with 67 additions and 92 deletions
|
|
@ -113,6 +113,9 @@ func (a *App) buildProjectBinary(p Project) error {
|
|||
if err := ensureOwnedByUnixUser(binaryPath, p.UnixUser, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := a.syncStaticAssetsForProject(p); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -186,3 +189,38 @@ func runGoBuildForUser(unixUser, repoDir, binaryPath string) error {
|
|||
"go", "-C", repoDir, "build", "-buildvcs=false", "-o", binaryPath, ".",
|
||||
)
|
||||
}
|
||||
|
||||
func (a *App) syncStaticAssetsForProject(p Project) error {
|
||||
projectDir, err := a.projectDirFor(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
repoStatic := filepath.Join(projectDir, "repo", "static")
|
||||
dataStatic := filepath.Join(projectDir, "data", "static")
|
||||
|
||||
if _, err := os.Stat(repoStatic); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
if err := os.MkdirAll(dataStatic, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ensureOwnedByUnixUser(dataStatic, p.UnixUser, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Preferred path: fast deterministic sync with deletes.
|
||||
if err := runCmd("sudo", "-n", "-u", p.UnixUser, "rsync", "-a", "--delete", repoStatic+"/", dataStatic+"/"); err == nil {
|
||||
return nil
|
||||
}
|
||||
// Fallback if rsync is unavailable: recreate target and copy.
|
||||
if err := runCmd("sudo", "-n", "-u", p.UnixUser, "rm", "-rf", dataStatic); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := runCmd("sudo", "-n", "-u", p.UnixUser, "mkdir", "-p", dataStatic); err != nil {
|
||||
return err
|
||||
}
|
||||
return runCmd("sudo", "-n", "-u", p.UnixUser, "cp", "-a", repoStatic+"/.", dataStatic+"/")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue