Refactor build and topdata path resolution through project config

This commit is contained in:
2026-04-24 19:11:10 +02:00
parent d880661599
commit 831d3b47da
11 changed files with 431 additions and 64 deletions
+14 -7
View File
@@ -16,12 +16,13 @@ import (
)
type ExtractResult struct {
ModulePath string
HAKPaths []string
Written int
Overwritten int
Removed int
Skipped int
ModulePath string
HAKPaths []string
DeletedArchivePaths []string
Written int
Overwritten int
Removed int
Skipped int
}
func Extract(p *project.Project, files ...string) (ExtractResult, error) {
@@ -36,7 +37,7 @@ func Extract(p *project.Project, files ...string) (ExtractResult, error) {
shouldExtractMod := len(allowed) == 0 || allowed[p.Config.Module.ResRef+".mod"]
if shouldExtractMod {
modulePath := filepath.Join(p.BuildDir(), p.Config.Module.ResRef+".mod")
modulePath := p.ModuleArchivePath()
input, err := os.Open(modulePath)
if err != nil {
return ExtractResult{}, fmt.Errorf("open module archive: %w", err)
@@ -94,6 +95,12 @@ func Extract(p *project.Project, files ...string) (ExtractResult, error) {
if len(failures) > 0 {
return result, errors.Join(failures...)
}
if p.Config.Extract.DeleteModuleArchiveAfterSuccess && result.ModulePath != "" {
if err := os.Remove(result.ModulePath); err != nil {
return result, fmt.Errorf("delete consumed module archive %s: %w", result.ModulePath, err)
}
result.DeletedArchivePaths = append(result.DeletedArchivePaths, result.ModulePath)
}
return result, nil
}