arj03 / ssb-browser-core

ssb-server in a browser
Other
50 stars 8 forks source link

SSB.removeDB() doesn't work #32

Open KyleMaas opened 3 years ago

KyleMaas commented 3 years ago

Turns out removeDB() doesn't actually remove the database's data. When it goes to delete the file here:

https://github.com/arj03/ssb-browser-core/blob/62d964fea34b87590019460e6ac04576aeb93f45/core-helpers.js#L25

The file object has the following properties (notice the deletable attribute):

closed: false
deletable: false
destroyed: false
filename: "/.ssb-lite/log.bipf"
opened: false
preferReadonly: false
readable: true
statable: true
writable: true
_close: ƒ close(req)
_destroy: ƒ destroy(req)
_events: {}
_eventsCount: 0
_maxListeners: undefined
_needsOpen: true
_open: ƒ open(req)
_pending: 0
_queued: []
_read: ƒ read(req)
_stat: ƒ stat(req)
_write: ƒ write(req)

I'm wondering if maybe we need to truncate the file instead. Thoughts?

KyleMaas commented 3 years ago

Pretty sure truncating the file wouldn't work. There's too much state held by async-append-only-log. This probably needs #198 to be done before we can actually make this work.