fix(places): keep the places index's build date only when every tile is unchanged; say the 500 km cap is for wide lookups

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 22:44:12 -08:00
1 parent ecb7e7cd68
commit d2797dbad2
7 files changed
+37 -19

No files matched your search

+18 -4
View File
@@ -505,11 +505,25 @@ if (tilesMode) {
// The new files are all written before tiles from an earlier build that
// this one has no rows for go, so a build that stops part way never leaves
// an index naming a removed tile.
const indexFile = path.join(outDir, 'index.json');
files.set(
'index.json',
keepBuiltIfUnchanged(files.get('index.json'), await readIfThere(indexFile)),
// The index holds only row counts, so its build date is kept only when
// every tile is unchanged too and no earlier tile is left over.
const earlierTiles = (await readdir(outDir)).filter((name) =>
/^-?\d+_-?\d+\.json$/.test(name),
);
let tilesUnchanged = earlierTiles.every((name) => files.has(name));
for (const [name, text] of files) {
if (!tilesUnchanged) break;
if (name === 'index.json') continue;
tilesUnchanged = (await readIfThere(path.join(outDir, name))) === text;
}
if (tilesUnchanged)
files.set(
'index.json',
keepBuiltIfUnchanged(
files.get('index.json'),
await readIfThere(path.join(outDir, 'index.json')),
),
);
for (const [name, text] of files)
await writeFile(path.join(outDir, name), text);
for (const name of await readdir(outDir))
+3 -1
View File
@@ -92,7 +92,9 @@ export function placeTileFiles(rows, meta) {
/**
* A pack file's new text, keeping the earlier build's `meta.built` when
* nothing else in the file changed, so rebuilding unchanged data leaves the
* file as it was.
* file as it was. A file that does not hold all of its pack's data (the
* places index) is passed through this only when the rest of the pack is
* unchanged too.
* @param {string} text The new file, JSON with a `meta.built` stamp.
* @param {string | undefined} earlier The file as it is now, if there is one.
*/