From 92b22d1c5073e7dc3f0139f895d34a2cb4af0346 Mon Sep 17 00:00:00 2001 From: Andrew Osheroff Date: Wed, 7 Aug 2019 12:54:00 +0200 Subject: [PATCH] add this._closed to prevent reopening --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 68922d0..93e5897 100644 --- a/index.js +++ b/index.js @@ -138,6 +138,7 @@ class Fuse extends Nanoresource { this.ops = ops this._thread = null this._handlers = this._makeHandlerArray() + this._closed = false const implemented = [binding.op_init, binding.op_error, binding.op_getattr] if (ops) { @@ -226,6 +227,8 @@ class Fuse extends Nanoresource { // Lifecycle methods _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._openCallback = cb @@ -263,6 +266,7 @@ class Fuse extends Nanoresource { } catch (err) { return cb(err) } + self._closed = true return cb(null) } }