From 38c5a1a11a6d9ce49e62eaa2d2ad9484d9146413 Mon Sep 17 00:00:00 2001 From: kdletters Date: Mon, 27 Jul 2026 12:05:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=8E=8B=E7=BC=A9=E6=97=A7?= =?UTF-8?q?=E7=89=88=E5=A4=87=E4=BB=BD=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 兼容旧 result 缺少 symlinks 清单的历史格式 补充缺字段元数据压缩回归测试 --- scripts/check-database-backup-to-oss.mjs | 5 ++++- scripts/database-backup-to-oss.mjs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/check-database-backup-to-oss.mjs b/scripts/check-database-backup-to-oss.mjs index 2e61af738..9bae19c58 100644 --- a/scripts/check-database-backup-to-oss.mjs +++ b/scripts/check-database-backup-to-oss.mjs @@ -371,9 +371,11 @@ async function assertDirectHistoryPublishesCatalogBeforeCleanup() { }; const baseline = await runDirectFilesBackup({...common, mode: 'full', uploadManifestFn: harness.uploadManifestFn}); const legacyResultFile = path.join(fixture.workDir, 'legacy-full-result.json'); + const legacyCatalogWithoutSymlinks = {...baseline.catalog}; + delete legacyCatalogWithoutSymlinks.symlinks; writeFileSync(legacyResultFile, `${JSON.stringify({ ...baseline, - catalog: baseline.catalog, + catalog: legacyCatalogWithoutSymlinks, }, null, 2)}\n`); const plan = discoverHistoryPlan({dataDir: fixture.dataDir}); let failure = null; @@ -441,6 +443,7 @@ async function assertDirectHistoryPublishesCatalogBeforeCleanup() { assertEqual(diskResult.catalog.fileCount, success.fileCount, '紧凑 result 仍应保留文件计数。'); const compactedLegacyResult = JSON.parse(readFileSync(legacyResultFile, 'utf8')); assertTrue(!Object.hasOwn(compactedLegacyResult.catalog, 'files'), '旧 result 中重复的 files 清单应在成功运行后压缩。'); + assertEqual(compactedLegacyResult.catalog.symlinkCount, 0, '缺少 symlinks 的旧 result 应按零个符号链接兼容迁移。'); assertTrue((success.metadataCleanup?.compactedResultCount ?? 0) >= 1, 'metadata 清理应报告已压缩旧 result。'); const historyCatalogObjectKey = state.historyCatalogs[0].objectKey; harness.objects.delete(historyCatalogObjectKey); diff --git a/scripts/database-backup-to-oss.mjs b/scripts/database-backup-to-oss.mjs index 3fe0a3191..95e6b54f9 100644 --- a/scripts/database-backup-to-oss.mjs +++ b/scripts/database-backup-to-oss.mjs @@ -1473,8 +1473,8 @@ function compactDirectFilesResult(result) { catalogObjectKey: catalog.catalogObjectKey, baselineCatalogId: catalog.baselineCatalogId, rootName: catalog.rootName, - fileCount: catalog.files.length, - symlinkCount: catalog.symlinks.length, + fileCount: Array.isArray(catalog.files) ? catalog.files.length : 0, + symlinkCount: Array.isArray(catalog.symlinks) ? catalog.symlinks.length : 0, }, }; }