兼容压缩旧版备份结果
Project CI / Repository checks (push) Successful in 1m4s
Project CI / Frontend tests (push) Successful in 1m36s
Project CI / Native shell tests (push) Successful in 2m20s
Project CI / Backend tests (push) Successful in 3m6s

兼容旧 result 缺少 symlinks 清单的历史格式
补充缺字段元数据压缩回归测试
This commit is contained in:
2026-07-27 12:05:33 +08:00
parent d38e8c913e
commit 38c5a1a11a
2 changed files with 6 additions and 3 deletions
+4 -1
View File
@@ -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);
+2 -2
View File
@@ -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,
},
};
}