Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delete database file from disk on db.delete #8693

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions yarn-project/kv-store/src/lmdb/store.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createDebugLogger } from '@aztec/foundation/log';

import { mkdirSync } from 'fs';
import { mkdtemp } from 'fs/promises';
import { mkdtemp, rm } from 'fs/promises';
import { type Database, type Key, type RootDatabase, open } from 'lmdb';
import { tmpdir } from 'os';
import { dirname, join } from 'path';
Expand Down Expand Up @@ -150,9 +150,13 @@ export class AztecLmdbStore implements AztecKVStore {
await this.#rootDb.clearAsync();
}

/** Deletes this store */
/** Deletes this store and removes the database files from disk */
async delete() {
await this.#rootDb.drop();
if (this.path) {
await rm(this.path, { recursive: true, force: true });
this.#log.verbose(`Deleted database files at ${this.path}`);
}
}

estimateSize(): { bytes: number } {
Expand Down
Loading