Skip to content

Protect Timeless Jewel cache integrity - #10307

Open
mcagnion wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
mcagnion:bugfix/timeless-jewel-cache-integrity
Open

mcagnion wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
mcagnion:bugfix/timeless-jewel-cache-integrity

Conversation

@mcagnion

@mcagnion mcagnion commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Description of the problem being solved:

Running PoB headless from a source checkout (the test suite, or a script using HeadlessWrapper.lua) leaves empty Timeless Jewel cache files behind. Headless Inflate() returns an empty string, and DataJewelFileLoader writes that result to src/Data/TimelessJewelData/<jewel>.bin. The empty file is newer than the .zip, so when the desktop app later starts from the same checkout it takes that file as up to date and loads empty jewel data, until the .bin is deleted or the archive changes.

With this PR the loader:

  • ignores an empty cache file and reads the compressed archive instead;
  • does not write the cache when Inflate() returns nothing (the loader returns nil);
  • writes a new cache to a temporary file and then replaces the old one, so a failed write keeps the previous cache (Windows cannot rename over an existing file, so the old cache is moved aside during the replacement).

A failed cache write is not fatal: the current load still uses the data it just inflated.

Headless decompression itself is not implemented here (#9748 covers that): headless runs still get no Timeless Jewel data, but they no longer break the cache used by the desktop app.

Steps taken to verify a working solution:

  • Regression test: a newer zero-byte cache falls back to the archive.
  • Regression test: an empty Inflate() result opens no cache file for writing.
  • Regression test: a failed replacement restores the previous cache and removes the temporary files.

@mcagnion
mcagnion force-pushed the bugfix/timeless-jewel-cache-integrity branch from f83a40a to 2d37d6b Compare August 29, 2026 07:29
Reject empty cached and inflated payloads so headless stubs cannot create zero-byte caches.

Write replacements through a checked temporary file and restore an existing cache when promotion fails.
@mcagnion
mcagnion force-pushed the bugfix/timeless-jewel-cache-integrity branch from 2d37d6b to 36b52f7 Compare August 29, 2026 08:21
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.

1 participant