feat: stream hashing and archive-entry import support

- Añade `computeHashesFromStream` para hashing desde streams
- Adapta `importDirectory` para procesar entradas internas usando `streamArchiveEntry`
- Añade tests unitarios para hashing por stream e import de entradas de archive
This commit is contained in:
2026-02-09 19:36:18 +01:00
parent 97a7f74685
commit 7ca465fb73
6 changed files with 183 additions and 3 deletions

View File

@@ -0,0 +1,24 @@
import { describe, it, expect } from 'vitest';
import { Readable } from 'stream';
import fs from 'fs/promises';
import path from 'path';
import { computeHashes, computeHashesFromStream } from '../../src/services/checksumService';
describe('services/checksumService (stream)', () => {
it('computeHashesFromStream produces same result as computeHashes(file)', async () => {
const data = Buffer.from('quasar-stream-test');
const tmpDir = await fs.mkdtemp(path.join(process.cwd(), 'tmp-checksum-'));
const tmpFile = path.join(tmpDir, 'test.bin');
await fs.writeFile(tmpFile, data);
const expected = await computeHashes(tmpFile);
const rs = Readable.from([data]);
const actual = await computeHashesFromStream(rs as any);
expect(actual).toEqual(expected);
await fs.rm(tmpDir, { recursive: true, force: true });
});
});