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
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.
113 lines
4.1 KiB
Go
113 lines
4.1 KiB
Go
package pipeline
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
|
|
"aego/core/errs"
|
|
"aego/core/log"
|
|
"aego/project"
|
|
)
|
|
|
|
// resolveMetadata runs under the import lock; importers cannot write metadata or mutate the record.
|
|
// Stable references are persisted before publishing artifacts that use them.
|
|
func (p *Pipeline) resolveMetadata(r *record, ctx *ImportContext) error {
|
|
resolver, ok := r.importer.(MetadataResolver)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
copyMeta := *r.meta
|
|
copyMeta.Settings = r.meta.Settings.Clone()
|
|
copyMeta.Subs = append([]SubAsset(nil), r.meta.Subs...)
|
|
copyCtx := *ctx
|
|
copyCtx.Meta = ©Meta
|
|
settings, err := resolver.ResolveMetadata(©Ctx)
|
|
if err != nil || settings == nil {
|
|
return err
|
|
}
|
|
if bytes.Equal(canonicalSettings(settings), canonicalSettings(r.meta.Settings)) {
|
|
return nil
|
|
}
|
|
if p.sourceTransactionReadOnlyMetas[r.path+MetaSuffix] {
|
|
return errs.New(errs.AssetSourceUnstable, "metadata needs changes but is a read-only source guard", log.F("path", r.path))
|
|
}
|
|
if p.shared || p.mode == MetaReadOnly {
|
|
return errs.New(errs.AssetBadMeta, "automatic asset references need a writable metadata owner", log.F("path", r.path))
|
|
}
|
|
transactionPath := r.path + MetaSuffix
|
|
if p.sourceTransactionMetas != nil {
|
|
if _, guarded := p.sourceTransactionMetas[transactionPath]; !guarded {
|
|
// Dependencies and cache-salted sources are also reimported during
|
|
// ApplySources. Their sidecars are not automatically part of the
|
|
// caller's history or rollback: never silently normalize one here.
|
|
return errs.New(errs.AssetBadMeta, "dependent metadata needs an explicit source transaction guard before references can be resolved", log.F("path", transactionPath))
|
|
}
|
|
}
|
|
if err := p.checkMetadataSnapshot(r); err != nil {
|
|
return err
|
|
}
|
|
path := p.abs(r.path) + MetaSuffix
|
|
before, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return errs.Wrap(err, errs.AssetBadMeta, "cannot read metadata before resolving references")
|
|
}
|
|
if expected, guarded := p.sourceTransactionMetas[transactionPath]; guarded && !sameSource(before, expected) {
|
|
return errs.New(errs.AssetSourceUnstable, "metadata changed during source transaction; resolve before retrying", log.F("path", r.path))
|
|
}
|
|
disk, err := ParseMeta(before, r.path+MetaSuffix)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if disk.Importer == "" {
|
|
disk.Importer = r.importer.ID()
|
|
}
|
|
for k, v := range r.importer.Defaults() {
|
|
if _, exists := disk.Settings[k]; !exists {
|
|
disk.Settings[k] = v
|
|
}
|
|
}
|
|
if !bytes.Equal(WriteMeta(disk), WriteMeta(r.meta)) {
|
|
return errs.New(errs.AssetSourceUnstable, "metadata changed during reference resolution; rescan before retrying", log.F("path", r.path))
|
|
}
|
|
copyMeta.Settings = settings.Clone()
|
|
after, err := os.ReadFile(path)
|
|
if err != nil || !bytes.Equal(before, after) {
|
|
return errs.New(errs.AssetSourceUnstable, "metadata is still being written", log.F("path", r.path))
|
|
}
|
|
published := WriteMeta(©Meta)
|
|
if p.sourceJournal != nil {
|
|
checked, err := p.sourceBytes(p.sourceJournalRoot, transactionPath)
|
|
if err != nil || !sameSource(checked, before) {
|
|
return errs.New(errs.AssetSourceUnstable, "metadata changed before reference publication", log.F("path", r.path))
|
|
}
|
|
if err := p.sourceJournal.authorize(transactionPath, published); err != nil {
|
|
return errs.Wrap(err, errs.VFSIO, "cannot protect resolved asset references")
|
|
}
|
|
if err := p.checkMetadataSnapshot(r); err != nil {
|
|
return err
|
|
}
|
|
if err := replaceSource(p.sourceJournalRoot, transactionPath, published); err != nil {
|
|
return errs.Wrap(err, errs.VFSIO, "cannot persist resolved asset references")
|
|
}
|
|
} else {
|
|
if err := p.checkMetadataSnapshot(r); err != nil {
|
|
return err
|
|
}
|
|
if err := project.WriteAtomic(path, published); err != nil {
|
|
return errs.Wrap(err, errs.VFSIO, "cannot persist resolved asset references")
|
|
}
|
|
}
|
|
r.captureMetadata(published)
|
|
if _, guarded := p.sourceTransactionMetas[transactionPath]; guarded {
|
|
p.sourceTransactionMetas[transactionPath] = published
|
|
}
|
|
if p.sourceJournal != nil && p.sourceTransactionCheckpoint != nil {
|
|
p.sourceTransactionCheckpoint("metadata", transactionPath)
|
|
}
|
|
r.meta = ©Meta
|
|
ctx.Meta = r.meta
|
|
p.metas[r.path+MetaSuffix] = true
|
|
p.rev++
|
|
return nil
|
|
}
|