diff --git a/src/lib/warcserializer.ts b/src/lib/warcserializer.ts index 1ce6914..b8ae227 100644 --- a/src/lib/warcserializer.ts +++ b/src/lib/warcserializer.ts @@ -27,6 +27,7 @@ export type WARCSerializerOpts = { export abstract class BaseSerializerBuffer { abstract write(chunk: Uint8Array): void; abstract readAll(): AsyncIterable; + abstract clear(): void; } // =========================================================================== @@ -42,6 +43,10 @@ export class SerializerInMemBuffer extends BaseSerializerBuffer { yield buff; } } + + clear() { + this.buffers = []; + } } // =========================================================================== diff --git a/src/node/warcserializer.ts b/src/node/warcserializer.ts index e860671..c00ffb4 100644 --- a/src/node/warcserializer.ts +++ b/src/node/warcserializer.ts @@ -75,10 +75,10 @@ export class TempFileBuffer extends warcserializer.SerializerInMemBuffer { yield buff; } - await this.deleteTempFile(); + await this.clear(); } - async deleteTempFile() { + override async clear() { if (this.filename) { await unlink(this.filename); this.filename = "";