-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add method to unlink storage #34
Conversation
af8c70f
to
4d8c94a
Compare
This adds `MultiCoreIndexer.prototype.unlink()` which unlinks all the index storage. Addresses #26.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first time i'm seeing ??=
in app code - took a second to understand that it short-circuits, which makes me have mixed feelings about its existence 😄
Changes look good overall, but had a small question that I'd consider non-blocking
this.#storage ??= await this.#createStorage() | ||
await unlinkStorage(this.#storage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm assuming there's an edge case that this accounts for but just in case: would a no-op (or throw) be possible here if the storage isn't initialized? e.g. if (!this.#storage) return
this seems to be performing operations that cancel each other out if the storage isn't already initialized, but maybe it's much more complex than that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be cases where the storage has been created on disk but hasn't been initialized in memory. For example:
- I start the app, index a bunch of stuff, and then close it.
- Later, I start the app and immediately unlink.
this.#storage
won't be created. We want to create it so we can unlink it.
My understanding is that creating the storage instance doesn't actually touch any files on disk. For example:
const RandomAccessFile = require("random-access-file")
const fs = require("node:fs")
new RandomAccessFile("my-file.txt")
fs.existsSync("my-file.txt")
// => false
Maybe it's worth adding an explainer comment about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah okay that makes more sense! I was under the impression that this class fully manages the storage on disk but if it's being done somewhere else, your reasoning is clearer. thanks!
I'll plan to merge this tomorrow barring objections. (Feel free to merge sooner if you want!) |
This adds
MultiCoreIndexer.prototype.unlink()
which unlinks all the index storage.Addresses #26. Depends on #35 because it uses
??=
.