fix(parser): detect large QQ chunked manifests

Use the manifest entry filename when sender statistics push the chunk metadata beyond the sniffer head.
This commit is contained in:
digua committed 2026-07-27 23:21:03 +08:00
1 parent eb2d1ea3bf
commit 9847e30855
2 files changed
+24 -16

No files matched your search

@@ -15,22 +15,29 @@ describe('shuakami-qq-exporter chunked parser', () => {
try {
mkdirSync(chunksDir)
writeFileSync(
manifestPath,
JSON.stringify({
metadata: { name: 'QQChatExporter', version: '0.1.0' },
chatInfo: { name: 'Test Group', type: 'group', selfUin: '100' },
statistics: { totalMessages: 2 },
chunked: {
format: 'jsonl',
chunksDir: 'chunks',
chunkFileExt: '.jsonl',
maxMessagesPerChunk: 50000,
maxBytesPerChunk: 52428800,
chunks: [{ relativePath: 'chunks/c000001.jsonl', count: 2 }],
},
})
)
const manifest = JSON.stringify({
metadata: { name: 'QQChatExporter', version: '0.1.0' },
chatInfo: { name: 'Test Group', type: 'group', selfUin: '100' },
statistics: {
totalMessages: 2,
senders: Array.from({ length: 1000 }, (_, index) => ({
uid: `u_${index}`,
name: `Member ${index} ${'x'.repeat(80)}`,
messageCount: 1,
percentage: 0.1,
})),
},
chunked: {
format: 'jsonl',
chunksDir: 'chunks',
chunkFileExt: '.jsonl',
maxMessagesPerChunk: 50000,
maxBytesPerChunk: 52428800,
chunks: [{ relativePath: 'chunks/c000001.jsonl', count: 2 }],
},
})
assert.ok(manifest.indexOf('"chunked"') > 64 * 1024)
writeFileSync(manifestPath, manifest)
writeFileSync(
join(chunksDir, 'c000001.jsonl'),
[
@@ -50,6 +50,7 @@ export const feature: FormatFeature = {
signatures: {
// V5 使用 metadata.format,0.1.x 将格式标识移至 chunked.format。
head: [/"format"\s*:\s*"chunked-jsonl"/, /"chunked"\s*:\s*\{[^{}]*"format"\s*:\s*"jsonl"/],
filename: [/^manifest\.json$/i],
requiredFields: ['metadata', 'chatInfo'],
},
}