This repository was archived by the owner on Jan 7, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11var assert = require ( 'assert' )
22var path = require ( 'path' )
3- var multicb = require ( 'multicb' )
43var xtend = require ( 'xtend' )
54var untildify = require ( 'untildify' )
65var importFiles = require ( './lib/import-files' )
@@ -210,17 +209,13 @@ Dat.prototype.close = function (cb) {
210209 var self = this
211210 self . _closed = true
212211
213- var done = multicb ( )
214- closeNet ( done ( ) )
215- closeFileWatch ( done ( ) )
216- closeArchive ( done ( ) )
217-
218- done ( cb )
219-
220- function closeArchive ( cb ) {
221- // self.archive.unreplicate()
222- self . archive . close ( cb )
223- }
212+ closeNet ( function ( err ) {
213+ if ( err ) debug ( 'Error while closing network:' , err . message )
214+ closeFileWatch ( function ( ) {
215+ // self.archive.unreplicate()
216+ self . archive . close ( cb )
217+ } )
218+ } )
224219
225220 function closeNet ( cb ) {
226221 if ( ! self . network ) return cb ( )
@@ -229,7 +224,11 @@ Dat.prototype.close = function (cb) {
229224
230225 function closeFileWatch ( cb ) {
231226 if ( ! self . importer ) return cb ( )
227+ // Emitting an event, as imported doesn't emit an event on
228+ // destroy and there is no other means to see if this was called.
229+ self . importer . emit ( 'destroy' )
232230 self . importer . destroy ( )
231+ delete self . importer
233232 process . nextTick ( cb )
234233 }
235234}
You can’t perform that action at this time.
0 commit comments