Files
aego/project/atomic.go
T
sanspie 50be5c04bc
ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Stage 12.5: Art Workspace and asset authoring
Add dockable Art tools, animation and previews, guarded asset workflows,
and the Web Asset Studio built on the shared Art Core. Expand English and
Russian documentation, interactive Try scenes, examples and editor icons.

Add audio waveform navigation, source analysis, guarded previews and a
browser Worker mixer. Preserve source changes and recovery with bounded
checks, and strengthen native, browser and interoperability CI.

Prepare version 0.12.5 and manually built native artifact candidates.
Fix the production site image demo build dependency.
Reuse immutable scene indices when capturing keyframes.
Wait for real Persist save/load completion in component tests.
Stabilize browser Game View captures outside pointer hover.
Aseprite interchange and persistent Audio EDL recovery remain limited;
the artifact workflow does not publish releases or change stable.
2026-11-15 10:37:50 +03:00

49 lines
1.1 KiB
Go

package project
import (
"errors"
"os"
"path/filepath"
"runtime"
)
// WriteAtomic writes a complete temporary file before publishing it with a
// rename. On native systems it flushes the temporary file before publication.
// This does not sync the containing directory, provide a compare-and-swap, or
// guarantee power-loss durability of the renamed directory entry.
func WriteAtomic(abs string, data []byte) error {
dir := filepath.Dir(abs)
if err := os.MkdirAll(dir, 0o755); err != nil {
return err
}
tmp, err := os.CreateTemp(dir, ".aego-*.tmp")
if err != nil {
return err
}
name := tmp.Name()
if _, err := tmp.Write(data); err != nil {
tmp.Close()
os.Remove(name)
return err
}
if err := tmp.Chmod(0o644); err != nil {
tmp.Close()
os.Remove(name)
return err
}
var syncErr error
// Browser/WASI storage adapters do not offer a portable native file flush.
if runtime.GOOS != "js" && runtime.GOOS != "wasip1" {
syncErr = tmp.Sync()
}
if err := errors.Join(syncErr, tmp.Close()); err != nil {
os.Remove(name)
return err
}
if err := os.Rename(name, abs); err != nil {
os.Remove(name)
return err
}
return nil
}