feat(archive): add rar extraction support

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-01 12:55:10 +02:00
co-authored by Claude Sonnet 5
parent a66143d312
commit ceddeddf3e
6 changed files with 60 additions and 0 deletions
+11
View File
@@ -6,6 +6,7 @@ import AdmZip from 'adm-zip';
import { ZipArchive } from 'archiver';
import * as tar from 'tar';
import _7z from '7zip-min';
import { createExtractorFromFile } from 'node-unrar-js';
import { register } from './registry.js';
const MAX_EXTRACTED_BYTES = 2 * 1024 * 1024 * 1024;
@@ -133,6 +134,15 @@ async function createTar7z(srcDir, outputPath, quality) {
}
}
async function extractRar(inputPath, destDir) {
const extractor = await createExtractorFromFile({ filepath: inputPath, targetPath: destDir });
const { files } = extractor.extract();
for (const _file of files) {
// Iterating fully is required: node-unrar-js writes each entry to disk
// lazily as this generator is advanced.
}
}
const EXTRACTORS = {
zip: extractZip,
tar: extractTarLike,
@@ -140,6 +150,7 @@ const EXTRACTORS = {
'tar.bz2': extractTarBz2,
'7z': extract7z,
'tar.7z': extractTar7z,
rar: extractRar,
};
const CREATORS = {
zip: createZip,