mirror of
https://github.com/fuse-friends/fuse-native
synced 2024-10-27 18:34:01 +00:00
Compare commits
No commits in common. "master" and "v2.2.3" have entirely different histories.
25
index.js
25
index.js
@ -230,8 +230,7 @@ class Fuse extends Nanoresource {
|
|||||||
|
|
||||||
return function (nativeHandler, opCode, ...args) {
|
return function (nativeHandler, opCode, ...args) {
|
||||||
const sig = signal.bind(null, nativeHandler)
|
const sig = signal.bind(null, nativeHandler)
|
||||||
const input = [...args]
|
const boundSignal = to ? autoTimeout(sig) : sig
|
||||||
const boundSignal = to ? autoTimeout(sig, input) : sig
|
|
||||||
const funcName = `_op_${name}`
|
const funcName = `_op_${name}`
|
||||||
if (!self[funcName] || !self._implemented.has(op)) return boundSignal(-1, ...defaults)
|
if (!self[funcName] || !self._implemented.has(op)) return boundSignal(-1, ...defaults)
|
||||||
return self[funcName].apply(self, [boundSignal, ...args])
|
return self[funcName].apply(self, [boundSignal, ...args])
|
||||||
@ -248,32 +247,16 @@ class Fuse extends Nanoresource {
|
|||||||
return process.nextTick(nativeSignal, ...arr)
|
return process.nextTick(nativeSignal, ...arr)
|
||||||
}
|
}
|
||||||
|
|
||||||
function autoTimeout (cb, input) {
|
function autoTimeout (cb) {
|
||||||
let called = false
|
let called = false
|
||||||
const timeout = setTimeout(timeoutWrap, to, TIMEOUT_ERRNO)
|
const timeout = setTimeout(timeoutWrap, to, TIMEOUT_ERRNO)
|
||||||
return timeoutWrap
|
return timeoutWrap
|
||||||
|
|
||||||
function timeoutWrap (err, ...args) {
|
function timeoutWrap (...args) {
|
||||||
if (called) return
|
if (called) return
|
||||||
called = true
|
called = true
|
||||||
|
|
||||||
clearTimeout(timeout)
|
clearTimeout(timeout)
|
||||||
|
cb(...args)
|
||||||
if (err === TIMEOUT_ERRNO) {
|
|
||||||
switch (name) {
|
|
||||||
case 'write':
|
|
||||||
case 'read':
|
|
||||||
return cb(TIMEOUT_ERRNO, 0, input[2].buffer)
|
|
||||||
case 'setxattr':
|
|
||||||
return cb(TIMEOUT_ERRNO, input[2].buffer)
|
|
||||||
case 'getxattr':
|
|
||||||
return cb(TIMEOUT_ERRNO, input[2].buffer)
|
|
||||||
case 'listxattr':
|
|
||||||
return cb(TIMEOUT_ERRNO, input[1].buffer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cb(err, ...args)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "fuse-native",
|
"name": "fuse-native",
|
||||||
"version": "2.2.6",
|
"version": "2.2.3",
|
||||||
"description": "Fully maintained fuse bindings for Node that aims to cover the entire FUSE api",
|
"description": "Fully maintained fuse bindings for Node that aims to cover the entire FUSE api",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
Loading…
Reference in New Issue
Block a user