Skip to content

Commit

Permalink
tempfilebuffer: add a clear() method to clear buffer / delete temp file
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer committed Dec 14, 2024
1 parent 1c9378c commit 43fae29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/lib/warcserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type WARCSerializerOpts = {
export abstract class BaseSerializerBuffer {
abstract write(chunk: Uint8Array): void;
abstract readAll(): AsyncIterable<Uint8Array>;
abstract clear(): void;
}

// ===========================================================================
Expand All @@ -42,6 +43,10 @@ export class SerializerInMemBuffer extends BaseSerializerBuffer {
yield buff;
}
}

clear() {
this.buffers = [];
}
}

// ===========================================================================
Expand Down
4 changes: 2 additions & 2 deletions src/node/warcserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down

0 comments on commit 43fae29

Please sign in to comment.