兼容压缩旧版备份结果
兼容旧 result 缺少 symlinks 清单的历史格式 补充缺字段元数据压缩回归测试
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user