Flatten Cache Folder
This commit is contained in:
@@ -45,7 +45,7 @@ func resolveReleasedPartsManifest(p *project.Project, progress func(string)) (ma
|
||||
if progress == nil {
|
||||
progress = func(string) {}
|
||||
}
|
||||
cachePath := filepath.Join(p.Root, ".cache", "topdata", partsManifestCacheFileName)
|
||||
cachePath := filepath.Join(p.Root, ".cache", partsManifestCacheFileName)
|
||||
if strings.TrimSpace(os.Getenv("SOW_PARTS_MANIFEST_REFRESH")) == "" {
|
||||
manifest, fresh, err := readFreshPartsManifestCache(cachePath, partsManifestCacheMaxAge)
|
||||
if err != nil {
|
||||
|
||||
@@ -25,8 +25,19 @@ func compiled2DAOutputDir(p *project.Project) string {
|
||||
return filepath.Join(p.TopDataBuildDir(), "2da")
|
||||
}
|
||||
|
||||
func defaultTopDataCacheDir(p *project.Project) string {
|
||||
return filepath.Join(p.Root, ".cache")
|
||||
}
|
||||
|
||||
func topDataBuildUsesRepoCache(p *project.Project) bool {
|
||||
return samePath(p.TopDataBuildDir(), defaultTopDataCacheDir(p))
|
||||
}
|
||||
|
||||
func compiledTLKOutputPath(p *project.Project) string {
|
||||
return filepath.Join(p.TopDataBuildDir(), "tlk", defaultTLKName)
|
||||
if topDataBuildUsesRepoCache(p) {
|
||||
return filepath.Join(p.BuildDir(), defaultTLKName)
|
||||
}
|
||||
return filepath.Join(p.TopDataBuildDir(), defaultTLKName)
|
||||
}
|
||||
|
||||
func compiledTLKOutputDir(p *project.Project) string {
|
||||
@@ -34,6 +45,9 @@ func compiledTLKOutputDir(p *project.Project) string {
|
||||
}
|
||||
|
||||
func wikiOutputRootDir(p *project.Project) string {
|
||||
if topDataBuildUsesRepoCache(p) {
|
||||
return filepath.Join(defaultTopDataCacheDir(p), wikiRootDirName)
|
||||
}
|
||||
return filepath.Join(p.TopDataBuildDir(), wikiRootDirName)
|
||||
}
|
||||
|
||||
|
||||
@@ -4030,7 +4030,7 @@ func TestBuildNativeRemovesStaleTopdataOutputs(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("BuildNative failed: %v", err)
|
||||
}
|
||||
if got, want := result.Output2DADir, filepath.Join(root, ".cache", "topdata", "2da"); got != want {
|
||||
if got, want := result.Output2DADir, filepath.Join(root, ".cache", "2da"); got != want {
|
||||
t.Fatalf("unexpected cached 2da output dir: got %q want %q", got, want)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(result.Output2DADir, "stale.2da")); !os.IsNotExist(err) {
|
||||
@@ -4056,10 +4056,10 @@ func TestBuildNativeWritesCompiledOutputsToCache(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("BuildNative failed: %v", err)
|
||||
}
|
||||
if got, want := result.Output2DADir, filepath.Join(root, ".cache", "topdata", "2da"); got != want {
|
||||
if got, want := result.Output2DADir, filepath.Join(root, ".cache", "2da"); got != want {
|
||||
t.Fatalf("unexpected 2da output dir: got %q want %q", got, want)
|
||||
}
|
||||
if got, want := result.OutputTLKDir, filepath.Join(root, ".cache", "topdata", "tlk"); got != want {
|
||||
if got, want := result.OutputTLKDir, filepath.Join(root, "build"); got != want {
|
||||
t.Fatalf("unexpected tlk output dir: got %q want %q", got, want)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(result.Output2DADir, "repadjust.2da")); err != nil {
|
||||
@@ -9525,7 +9525,7 @@ func testProject(root string) *project.Project {
|
||||
Paths: project.PathConfig{Source: "src", Assets: "assets", Build: "build"},
|
||||
TopData: project.TopDataConfig{
|
||||
Source: "topdata",
|
||||
Build: ".cache/topdata",
|
||||
Build: ".cache",
|
||||
ReferenceBuilder: "reference",
|
||||
Assets: ".",
|
||||
},
|
||||
|
||||
@@ -42,7 +42,7 @@ func TestBuildNativeGeneratesAndSkipsWikiPages(t *testing.T) {
|
||||
if result.WikiPages != 1 {
|
||||
t.Fatalf("expected one generated entity page, got %d", result.WikiPages)
|
||||
}
|
||||
pagePath := filepath.Join(root, ".cache", "topdata", "wiki", "pages", "skills", "athletics.txt")
|
||||
pagePath := filepath.Join(root, ".cache", "wiki", "pages", "skills", "athletics.txt")
|
||||
got, err := os.ReadFile(pagePath)
|
||||
if err != nil {
|
||||
t.Fatalf("read generated page: %v", err)
|
||||
@@ -54,7 +54,7 @@ func TestBuildNativeGeneratesAndSkipsWikiPages(t *testing.T) {
|
||||
if !strings.Contains(text, "Ability: Strength.") || !strings.Contains(text, " * Climb") {
|
||||
t.Fatalf("expected description to be rendered into wiki page:\n%s", text)
|
||||
}
|
||||
statusPath := filepath.Join(root, ".cache", "topdata", "wiki", "pages", "meta", "wikistatus.txt")
|
||||
statusPath := filepath.Join(root, ".cache", "wiki", "pages", "meta", "wikistatus.txt")
|
||||
statusRaw, err := os.ReadFile(statusPath)
|
||||
if err != nil {
|
||||
t.Fatalf("read status page: %v", err)
|
||||
@@ -62,10 +62,10 @@ func TestBuildNativeGeneratesAndSkipsWikiPages(t *testing.T) {
|
||||
if !strings.Contains(string(statusRaw), "**Vanilla:** 1\\\\") {
|
||||
t.Fatalf("expected wiki status summary to count vanilla page:\n%s", string(statusRaw))
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(root, ".cache", "topdata", "wiki", "state.json")); err != nil {
|
||||
if _, err := os.Stat(filepath.Join(root, ".cache", "wiki", "state.json")); err != nil {
|
||||
t.Fatalf("expected state file after first build: %v", err)
|
||||
}
|
||||
stateBefore, err := loadWikiState(filepath.Join(root, ".cache", "topdata", "wiki", "state.json"))
|
||||
stateBefore, err := loadWikiState(filepath.Join(root, ".cache", "wiki", "state.json"))
|
||||
if err != nil {
|
||||
t.Fatalf("read state before second build: %v", err)
|
||||
}
|
||||
@@ -120,7 +120,7 @@ func TestBuildAndPackageBuildsWikiOnlyWhenRequested(t *testing.T) {
|
||||
if result.WikiOutputDir != "" || result.WikiPages != 0 {
|
||||
t.Fatalf("expected wiki generation to be skipped by default, got dir=%q pages=%d", result.WikiOutputDir, result.WikiPages)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(root, ".cache", "topdata", "wiki", "state.json")); !os.IsNotExist(err) {
|
||||
if _, err := os.Stat(filepath.Join(root, ".cache", "wiki", "state.json")); !os.IsNotExist(err) {
|
||||
t.Fatalf("expected no wiki state without explicit wiki build, got %v", err)
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ func TestBuildAndPackageBuildsWikiOnlyWhenRequested(t *testing.T) {
|
||||
if result.WikiPages != 1 {
|
||||
t.Fatalf("expected one generated wiki page when requested, got %d", result.WikiPages)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(root, ".cache", "topdata", "wiki", "state.json")); err != nil {
|
||||
if _, err := os.Stat(filepath.Join(root, ".cache", "wiki", "state.json")); err != nil {
|
||||
t.Fatalf("expected wiki state after explicit wiki build: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ func TestBuildNativeRegeneratesWikiWhenTLKTextChanges(t *testing.T) {
|
||||
if _, err := BuildNative(proj, nil); err != nil {
|
||||
t.Fatalf("BuildNative after text change failed: %v", err)
|
||||
}
|
||||
pagePath := filepath.Join(root, ".cache", "topdata", "wiki", "pages", "skills", "athletics.txt")
|
||||
pagePath := filepath.Join(root, ".cache", "wiki", "pages", "skills", "athletics.txt")
|
||||
got, err := os.ReadFile(pagePath)
|
||||
if err != nil {
|
||||
t.Fatalf("read regenerated page: %v", err)
|
||||
@@ -230,7 +230,7 @@ func TestBuildPackageIgnoresWikiSourcesForFreshness(t *testing.T) {
|
||||
t.Fatalf("BuildNative failed: %v", err)
|
||||
}
|
||||
|
||||
pagePath := filepath.Join(root, ".cache", "topdata", "wiki", "pages", "skills", "athletics.txt")
|
||||
pagePath := filepath.Join(root, ".cache", "wiki", "pages", "skills", "athletics.txt")
|
||||
newTime := time.Now().Add(2 * time.Second)
|
||||
if err := os.Chtimes(pagePath, newTime, newTime); err != nil {
|
||||
t.Fatalf("touch wiki page: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user