Revert "[fix] solution/site: 대장에 없는 자산을 지우지 않는다 — 첫 배포에 운영 사이트가 끊겼다"
This reverts commit 292cf26fd9.
This commit is contained in:
1 parent
22447ae041
commit
9a4bc0e123
3 files changed
+3
-55
No files matched your search
@@ -531,8 +531,8 @@ function readAssetLedger(assetsDir: string): AssetBuild[] {
|
||||
};
|
||||
return Array.isArray(parsed.builds) ? parsed.builds : [];
|
||||
} catch {
|
||||
// 없거나 깨졌으면 빈 대장으로 시작한다. 디스크에 있던 파일은 pruneAssets 가
|
||||
// "처음 본 것" 으로 입양하므로 지워지지 않는다 — 그 ★ 주석이 이 실패의 근거다.
|
||||
// 없거나 깨졌으면 이번 빌드부터 다시 센다. 옛 파일은 그대로 남는다 —
|
||||
// 대장을 못 읽었다고 지우는 쪽으로 실패하면 사이트가 깨진다.
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -545,32 +545,13 @@ function readAssetLedger(assetsDir: string): AssetBuild[] {
|
||||
*/
|
||||
function pruneAssets(assetsDir: string, current: string[]) {
|
||||
const signature = (files: string[]) => [...files].sort().join('\n');
|
||||
const now = new Date().toISOString();
|
||||
const previous = readAssetLedger(assetsDir);
|
||||
const head: AssetBuild = {at: now, files: current};
|
||||
const head: AssetBuild = {at: new Date().toISOString(), files: current};
|
||||
const builds =
|
||||
previous[0] && signature(previous[0].files) === signature(current)
|
||||
? [head, ...previous.slice(1)]
|
||||
: [head, ...previous];
|
||||
|
||||
/**
|
||||
* ★ 대장에 없는 파일은 **지우지 않는다.** 언제 깔렸는지 모를 뿐이므로 지금 처음 본 것으로
|
||||
* 치고 보관 기간을 새로 준다.
|
||||
*
|
||||
* 이 줄이 없어서 실제로 운영 사이트가 끊겼다(2026-09-07). 대장은 이 기능과 함께 생겼으니
|
||||
* **배포 직후 첫 실행에는 대장이 없다** — 그때 디스크에 있던 기존 자산이 전부 "대장에 없음"
|
||||
* 으로 분류돼 한꺼번에 삭제됐고, 아직 다시 굽지 않은 사이트의 CSS 가 통째로 404 가 됐다.
|
||||
* 옛 자산을 남기려고 만든 코드가 첫 실행에서 정확히 반대로 동작했다.
|
||||
*/
|
||||
const recorded = new Set(builds.flatMap((build) => build.files));
|
||||
const adopted = listRelativeFiles(assetsDir).filter(
|
||||
(file) => file !== ASSET_LEDGER && !recorded.has(file),
|
||||
);
|
||||
if (adopted.length > 0) {
|
||||
builds.push({at: now, files: adopted});
|
||||
console.log(` ✓ 대장에 없던 자산 ${adopted.length}개를 보관 대상으로 넣는다`);
|
||||
}
|
||||
|
||||
const cutoff = Date.now() - ASSET_RETENTION_DAYS * 24 * 60 * 60 * 1000;
|
||||
const kept = builds.filter(
|
||||
(build, index) => index < ASSET_MIN_BUILDS || Date.parse(build.at) >= cutoff,
|
||||
|
||||
Reference in new issue
Block a user