diff --git a/public/js/offline_data.js b/public/js/offline_data.js index 3fc4a2e..c491bb7 100644 --- a/public/js/offline_data.js +++ b/public/js/offline_data.js @@ -274,6 +274,23 @@ class DataFileRow { // Called by OfflineDataControl once RegionPicker's Apply has saved a // new selection — not tied to a button of this row's own. async triggerBuild() { + this._statusEl.textContent = "Checking…"; + try { + // false (not null/true — see offline_update_available? in + // pmtiles_builder.rb) means the just-saved selection matches what's + // already on disk byte-for-byte: same countries, nothing upstream + // changed. Rebuilding would just burn bandwidth/CPU to reproduce + // the same file, so skip it. null (never built, or can't tell) + // still falls through to building below. + const check = await (await fetch(this._checkUpdateUrl)).json(); + if (check.update_available === false) { + this._refreshStatus(); + return; + } + } catch { + // couldn't tell — fall through and build rather than silently skip + } + this._statusEl.textContent = "Starting…"; try { const response = await fetch(this._buildUrl, { method: "POST" });