mirror of
https://github.com/fuse-friends/fuse-native
synced 2024-10-27 18:34:01 +00:00
add this._closed to prevent reopening
This commit is contained in:
parent
b48d260d9e
commit
92b22d1c50
4
index.js
4
index.js
@ -138,6 +138,7 @@ class Fuse extends Nanoresource {
|
|||||||
this.ops = ops
|
this.ops = ops
|
||||||
this._thread = null
|
this._thread = null
|
||||||
this._handlers = this._makeHandlerArray()
|
this._handlers = this._makeHandlerArray()
|
||||||
|
this._closed = false
|
||||||
|
|
||||||
const implemented = [binding.op_init, binding.op_error, binding.op_getattr]
|
const implemented = [binding.op_init, binding.op_error, binding.op_getattr]
|
||||||
if (ops) {
|
if (ops) {
|
||||||
@ -226,6 +227,8 @@ class Fuse extends Nanoresource {
|
|||||||
// Lifecycle methods
|
// Lifecycle methods
|
||||||
|
|
||||||
_open (cb) {
|
_open (cb) {
|
||||||
|
if (this._closed) return process.nextTick(cb, new Error('Cannot reopen a closed FUSE instance.'))
|
||||||
|
|
||||||
this._thread = Buffer.alloc(binding.sizeof_fuse_thread_t)
|
this._thread = Buffer.alloc(binding.sizeof_fuse_thread_t)
|
||||||
this._openCallback = cb
|
this._openCallback = cb
|
||||||
|
|
||||||
@ -263,6 +266,7 @@ class Fuse extends Nanoresource {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
return cb(err)
|
return cb(err)
|
||||||
}
|
}
|
||||||
|
self._closed = true
|
||||||
return cb(null)
|
return cb(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user