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

Add opts.persistentKey (to avoid writing key to disk) #43

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

LuKks
Copy link
Contributor

@LuKks LuKks commented Jan 4, 2023

No description provided.

@LuKks
Copy link
Contributor Author

LuKks commented Jan 4, 2023

C'mon Windows! I know you can do it

@@ -90,7 +91,7 @@ module.exports = class Corestore extends EventEmitter {
if (err && err.code !== 'ENOENT') return reject(err)
if (err || st.size < 32 || this._overwrite) {
const key = this.primaryKey || crypto.randomBytes(32)
return this._keyStorage.write(0, key, err => {
return this._keyStorage.write(0, this.persistentKey ? key : b4a.alloc(0), err => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont write anything if you are not persisting. just return before instead and resolve

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the issue is that we still need to lock from the storage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I don't remember if without writing then the file exists anyway, maybe it does, will check later!

@@ -25,6 +25,7 @@ module.exports = class Corestore extends EventEmitter {
this.cores = root ? root.cores : new Map()
this.cache = !!opts.cache
this.primaryKey = opts.primaryKey || null
this.persistentKey = opts.persistentKey !== false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use a better name i think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants