fix: 7z parser handles solid archives with empty Compressed column

This commit is contained in:
admin
2026-03-21 21:18:33 +01:00
parent a90f653314
commit bf093cdfca

View File

@@ -55,20 +55,23 @@ function parse7zOutput(output: string): FileEntry[] {
if (!inFileList) continue; if (!inFileList) continue;
// Parse: Date Time Attr Size Compressed Name // Parse: Date Time Attr Size [Compressed] Name
// 2024-01-15 10:30:00 ....A 12345 10234 folder/file.stl // In solid archives, Compressed is only shown for the first file.
// 2024-06-14 16:23:14 ....A 225863 595992954 IDP02S02_Steak/01.jpg
// 2024-06-14 16:26:30 ....A 188040 IDP02S02_Steak/02.jpg
const match = trimmed.match( const match = trimmed.match(
/^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\s+\S+\s+(\d+)\s+(\d+)\s+(.+)$/ /^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\s+(\S+)\s+(\d+)\s+(\d+\s+)?(.+)$/
); );
if (match) { if (match) {
const [, uncompressedStr, compressedStr, filePath] = match; const [, attr, uncompressedStr, compressedRaw, filePath] = match;
// Skip directory entries // Skip directory entries (D attribute or trailing slash)
if (filePath.endsWith("/") || filePath.endsWith("\\")) continue; if (attr.startsWith("D") || filePath.endsWith("/") || filePath.endsWith("\\")) continue;
// Skip entries with 0 size (typically directories without trailing slash) // Skip entries with 0 size
if (uncompressedStr === "0" && compressedStr === "0") continue; if (uncompressedStr === "0") continue;
const compressedStr = compressedRaw?.trim() || uncompressedStr;
const ext = path.extname(filePath).toLowerCase(); const ext = path.extname(filePath).toLowerCase();
entries.push({ entries.push({
path: filePath, path: filePath,