Skip to content

Store test world files as a single compressed zip to reduce LFS bandwidth#2272

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/zip-wld-files
Draft

Store test world files as a single compressed zip to reduce LFS bandwidth#2272
Copilot wants to merge 2 commits intomainfrom
copilot/zip-wld-files

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 29, 2026

85 .wld test fixtures were consuming 476 MB of git LFS storage. Replace them with a single world-files.zip (88 MB, 81% reduction) using maximum zlib compression, tracked via LFS.

Changes

  • world-files.zip — all 85 .wld files packed at compression level 9; added to LFS via .gitattributes
  • ModuleInit.cs — pre-test extraction: world-files.zip is unpacked to WorldFiles/ before any test runs; thread-safe with path traversal guard
  • TEdit.Tests.csproj — copies world-files.zip to output instead of individual .wld files
  • .gitattributes — removed global *.wld LFS filter; added scoped src/TEdit.Tests/WorldFiles/*.zip LFS filter
  • .gitignore — allowlist exception for src/TEdit.Tests/WorldFiles/*.zip; ignore extracted *.wld files so they don't get accidentally committed
  • All 85 .wld files removed from git tracking (git rm --cached)

Extraction logic

private static void ExtractWorldFiles()
{
    var worldFilesDir = Path.Combine(AppContext.BaseDirectory, "WorldFiles");
    var zipPath = Path.Combine(worldFilesDir, "world-files.zip");
    if (!File.Exists(zipPath)) return;

    lock (_extractLock)
    {
        using var archive = ZipFile.OpenRead(zipPath);
        foreach (var entry in archive.Entries)
        {
            // ... path traversal check, then:
            if (!File.Exists(destinationPath))
                entry.ExtractToFile(destinationPath);
        }
    }
}

Extraction is idempotent — already-present .wld files are skipped, so subsequent test runs pay no extraction cost.

Copilot AI linked an issue Apr 29, 2026 that may be closed by this pull request
- Create world-files.zip with all 85 .wld files (max compression, 88 MB vs 476 MB)
- Track WorldFiles zip via LFS, remove wld LFS tracking
- Update gitignore to allow WorldFiles zip, ignore extracted wld files
- Update TEdit.Tests.csproj to copy zip instead of wld files
- Update ModuleInit.cs to extract zip before tests run
- Remove all 85 .wld files from git tracking

Agent-Logs-Url: https://github.com/TEdit/Terraria-Map-Editor/sessions/5c42bc50-b489-4d8a-b546-2694b330a2e5

Co-authored-by: BinaryConstruct <456755+BinaryConstruct@users.noreply.github.com>
Copilot AI changed the title [WIP] Zip world files and update unit tests Store test world files as a single compressed zip to reduce LFS bandwidth Apr 29, 2026
Copilot AI requested a review from BinaryConstruct April 29, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zip world files

2 participants