Adding static unmount + force option

auto-timeout
Andrew Osheroff 4 years ago
parent de825b61e6
commit f7dde5d16a

@ -135,6 +135,7 @@ class Fuse extends Nanoresource {
this.mnt = path.resolve(mnt)
this.ops = ops
this._force = !!opts.force
this._thread = null
this._handlers = this._makeHandlerArray()
@ -225,9 +226,26 @@ class Fuse extends Nanoresource {
}
}
// Static methods
static unmount (mnt, cb) {
const mnt = JSON.stringify(mnt)
const cmd = IS_OSX ? `diskutil umount ${mnt}` : `fusermount -uz ${mnt}`
exec(cmd, err => {
if (err) return cb(err)
return cb(null)
})
}
// Lifecycle methods
_open (cb) {
const self = this
if (this._force) return Fuse.unmount(this.mnt, open)
return open()
function open (err) {
if (err) return cb(err)
this._thread = Buffer.alloc(binding.sizeof_fuse_thread_t)
this._openCallback = cb
@ -248,6 +266,7 @@ class Fuse extends Nanoresource {
})
})
}
}
_close (cb) {
if (this._closed) return process.nextTick(cb, null)
@ -255,7 +274,7 @@ class Fuse extends Nanoresource {
const mnt = JSON.stringify(this.mnt)
const cmd = IS_OSX ? `diskutil umount ${mnt}` : `fusermount -uz ${mnt}`
exec(cmd, (err, stdout, stderr) => {
Fuse.unmount(mnt, err => {
if (err) return cb(err)
nativeUnmount()
})

Loading…
Cancel
Save