← back to Fabricut Landing
fabricut: make localizer restore-map merge-safe (never clobber prior reversibility)
5986a141c1e7505ce09f87a512a905a6aaed3e48 · 2026-08-24 19:13:04 -0700 · Steve Abrams
The daily-post recurrence guard runs localize-images.js --apply every day; a
steady-state run finds 0 S3 rows and previously rebuilt an EMPTY restore-map,
wiping reversibility. Now it MERGES by dw_sku (keeps the oldest recorded original
S3 url, updates the localized target), so the 1325-row map survives empty runs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Files touched
M data/image-restore-map.jsonM scripts/localize-images.js
Diff
commit 5986a141c1e7505ce09f87a512a905a6aaed3e48
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon Aug 24 19:13:04 2026 -0700
fabricut: make localizer restore-map merge-safe (never clobber prior reversibility)
The daily-post recurrence guard runs localize-images.js --apply every day; a
steady-state run finds 0 S3 rows and previously rebuilt an EMPTY restore-map,
wiping reversibility. Now it MERGES by dw_sku (keeps the oldest recorded original
S3 url, updates the localized target), so the 1325-row map survives empty runs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
data/image-restore-map.json | 15 ++++++---------
scripts/localize-images.js | 21 ++++++++++++++++++---
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/data/image-restore-map.json b/data/image-restore-map.json
index d306459..dbd7b2d 100644
--- a/data/image-restore-map.json
+++ b/data/image-restore-map.json
@@ -1,18 +1,15 @@
{
- "built_at": "2026-08-25T02:10:17.500Z",
- "applied": true,
+ "built_at": "2026-08-25T02:12:53.233Z",
+ "last_run_applied": true,
"public_base": "https://fabricut.designerwallcoverings.com/img/fabricut",
"rows": 1325,
+ "last_run_localized": 0,
"download_stats": {
"downloaded": 0,
- "cached": 1310,
- "failed": 2,
+ "cached": 0,
+ "failed": 0,
"bytes": 0,
- "failUrls": [
- "403 https://s3.us-east-1.amazonaws.com/fabricut.img/img/product_images/secondary_images/2200910_stylized_secondary.jpg",
- "err https://s3.us-east-1.amazonaws.com/fabricut.img/img/product_images/secondary_images/2200906_stylized_secondary.jpg"
- ],
- "droppedDead": 2
+ "failUrls": []
},
"restore": [
{
diff --git a/scripts/localize-images.js b/scripts/localize-images.js
index 37ce4f0..942ff95 100644
--- a/scripts/localize-images.js
+++ b/scripts/localize-images.js
@@ -140,10 +140,25 @@ async function main() {
console.log(` ...images processed dl=${stats.downloaded} cached=${stats.cached} fail=${stats.failed}`);
}
+ // MERGE into the canonical restore-map — NEVER clobber prior reversibility records.
+ // A steady-state daily run finds 0 S3 rows; it must not wipe the original 1325-row map.
+ // Keyed by dw_sku; a row's mapping updates only if this run actually localized it.
+ let prior = { restore: [] };
+ try { prior = JSON.parse(fs.readFileSync(MAP_OUT, 'utf8')); } catch {}
+ const byKey = new Map((prior.restore || []).map(r => [r.dw_sku, r]));
+ for (const rec of restore) {
+ const ex = byKey.get(rec.dw_sku) || { dw_sku: rec.dw_sku };
+ // keep the OLDEST recorded `old` (the true original S3 url), update `new`
+ if (rec.image_url) ex.image_url = { old: (ex.image_url && ex.image_url.old) || rec.image_url.old, new: rec.image_url.new };
+ if (rec.all_images) ex.all_images = { old: (ex.all_images && ex.all_images.old) || rec.all_images.old, new: rec.all_images.new };
+ byKey.set(rec.dw_sku, ex);
+ }
+ const merged = [...byKey.values()];
fs.writeFileSync(MAP_OUT, JSON.stringify({
- built_at: new Date().toISOString(), applied: APPLY, public_base: PUBLIC_BASE,
- rows: restore.length, download_stats: { ...stats, failUrls: stats.failUrls.slice(0, 50) },
- restore,
+ built_at: new Date().toISOString(), last_run_applied: APPLY, public_base: PUBLIC_BASE,
+ rows: merged.length, last_run_localized: restore.length,
+ download_stats: { ...stats, failUrls: stats.failUrls.slice(0, 50) },
+ restore: merged,
}, null, 2));
console.log(`[localize] downloaded=${stats.downloaded} cached=${stats.cached} failed=${stats.failed} ` +
`bytes=${(stats.bytes / 1e6).toFixed(1)}MB | restore-map: ${restore.length} rows -> ${MAP_OUT}`);
← 3a38772 fabricut: localize all images off vendor S3 to DW public URL
·
back to Fabricut Landing
·
auto-data-snapshot: 2026-08-24T20:06:56 (1 data files) — dat a94cc21 →