Skip to content

Commit a065fa6

Browse files
committed
Fixed bug in cleanup
1 parent aa10f4d commit a065fa6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,14 @@ class HyperdriveDaemon extends EventEmitter {
7373

7474
async close () {
7575
if (this._isClosed) return Promise.resolve()
76-
if (this.networking) await this.networking.close()
77-
this._isClosed = true
78-
}
79-
80-
async cleanup () {
8176
if (this.fuse && this.fuse.fuseConfigured) await this.fuse.unmount()
82-
await this.megastore.close()
77+
if (this.networking) await this.networking.close()
8378
await this.db.close()
79+
this._isClosed = true
8480
}
8581
}
8682

87-
module.exports = async function start (opts = {}) {
83+
async function start (opts = {}) {
8884
const metadata = opts.metadata || await new Promise((resolve, reject) => {
8985
loadMetadata((err, metadata) => {
9086
if (err) return reject(err)
@@ -213,7 +209,7 @@ function wrap (metadata, methods, opts) {
213209
function createMainHandlers (server, daemon) {
214210
return {
215211
stop: async (call) => {
216-
await daemon.cleanup()
212+
await daemon.close()
217213
setTimeout(() => {
218214
console.error('Daemon is exiting.')
219215
server.forceShutdown()
@@ -230,4 +226,6 @@ function createMainHandlers (server, daemon) {
230226

231227
if (require.main === module) {
232228
start()
229+
} else {
230+
module.exports = start
233231
}

0 commit comments

Comments
 (0)