Skip to content

Commit

Permalink
Remove 'done' event
Browse files Browse the repository at this point in the history
  • Loading branch information
MKPLKN committed Sep 2, 2024
1 parent 05f6208 commit 97dadc6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
4 changes: 0 additions & 4 deletions lib/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ module.exports = class Monitor extends ReadyResource {
}

this.emit('update')
if (this.stats.totalBytes === this.stats.bytes) {
this.emit('done')
this.close()
}
}
}

Expand Down
12 changes: 1 addition & 11 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ test('drive.list (recursive false) ignore', async (t) => {
})

test('upload/download can be monitored', async (t) => {
t.plan(23)
t.plan(17)
const { corestore, drive, swarm, mirror } = await testenv(t.teardown)
swarm.on('connection', (conn) => corestore.replicate(conn))
swarm.join(drive.discoveryKey, { server: true, client: false })
Expand All @@ -1590,11 +1590,6 @@ test('upload/download can be monitored', async (t) => {
t.is(monitor.stats.totalBlocks, 2)
t.is(monitor.stats.totalBytes, bytes)
})
monitor.on('done', () => {
t.is(monitor.stats.blocks, 2)
t.is(monitor.stats.bytes, bytes)
})
monitor.on('close', () => t.pass('Monitor is closed after its done'))
}

await drive.put(file, buffer)
Expand All @@ -1611,11 +1606,6 @@ test('upload/download can be monitored', async (t) => {
t.is(monitor.stats.totalBlocks, 2)
t.is(monitor.stats.totalBytes, bytes)
})
monitor.on('done', () => {
t.is(monitor.stats.blocks, 2)
t.is(monitor.stats.bytes, bytes)
})
monitor.on('close', () => t.pass('Monitor is closed after its done'))
}

await mirror.drive.get(file)
Expand Down

0 comments on commit 97dadc6

Please sign in to comment.