diff --git a/internal/pipeline/build.go b/internal/pipeline/build.go index 854a58c..59525b6 100644 --- a/internal/pipeline/build.go +++ b/internal/pipeline/build.go @@ -186,7 +186,7 @@ func planOrBuildHAKs(p *project.Project, progress ProgressFunc, writeArchives bo } progressf(progress, "Collecting asset resources...") - assetResources, err := collectAssetResources(p, writeArchives) + assetResources, err := collectAssetResources(p, false) if err != nil { return BuildResult{}, err } @@ -209,6 +209,12 @@ func planOrBuildHAKs(p *project.Project, progress ProgressFunc, writeArchives bo if err != nil { return BuildResult{}, err } + if writeArchives { + chunks, err = hydrateHAKChunks(p, chunks) + if err != nil { + return BuildResult{}, err + } + } progressf(progress, "Resolving module HAK order...") moduleHakOrder, err := resolveModuleHAKOrder(p, chunks) if err != nil { @@ -338,6 +344,43 @@ func filterHAKChunksByName(chunks []hakChunk, archiveNames []string) ([]hakChunk return filtered, nil } +func hydrateHAKChunks(p *project.Project, chunks []hakChunk) ([]hakChunk, error) { + if len(chunks) == 0 { + return chunks, nil + } + + lfsAssets, err := collectLFSAssetInfo(p) + if err != nil { + return nil, err + } + + hydrated := make([]hakChunk, 0, len(chunks)) + for _, chunk := range chunks { + nextChunk := chunk + nextChunk.Assets = make([]assetResource, 0, len(chunk.Assets)) + for _, asset := range chunk.Assets { + if !strings.HasPrefix(asset.ContentID, "lfs:") { + nextChunk.Assets = append(nextChunk.Assets, asset) + continue + } + + info, ok := lfsAssets[filepath.ToSlash(asset.Rel)] + if !ok { + return nil, fmt.Errorf("missing LFS metadata for %s", asset.Rel) + } + resource, err := lfsPathResource(filepath.Join(p.AssetsDir(), filepath.FromSlash(asset.Rel)), info, true) + if err != nil { + return nil, err + } + asset.Resource = resource + nextChunk.Assets = append(nextChunk.Assets, asset) + } + hydrated = append(hydrated, nextChunk) + } + + return hydrated, nil +} + func progressf(progress ProgressFunc, message string) { if progress != nil { progress(message)