Add flush handler and make Streamer.write await close
This commit is contained in:
20
ops/flush.js
Normal file
20
ops/flush.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const Fuse = require('fuse-native')
|
||||
const Errors = require('../../shared/Errors')
|
||||
const Message = require('../../shared/Message')
|
||||
const connector = require('../connector')
|
||||
|
||||
module.exports = exports = function (path, fd, cb) {
|
||||
console.log('[FLUSH]')
|
||||
connector.send(
|
||||
Message.route('fs.flush')
|
||||
.data({ path, descriptor: fd })
|
||||
.expect_response(msg => {
|
||||
if ( msg.error() ) {
|
||||
return Errors.toCallback(cb, msg.error())
|
||||
}
|
||||
|
||||
console.log('[/FLUSH]')
|
||||
return process.nextTick(cb, 0)
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -4,6 +4,7 @@ const Message = require('../../shared/Message')
|
||||
const connector = require('../connector')
|
||||
|
||||
module.exports = exports = function (path, fd, cb) {
|
||||
console.log('[RELEASE]')
|
||||
connector.send(
|
||||
Message.route('fs.release')
|
||||
.data({ path, descriptor: fd })
|
||||
@@ -12,6 +13,7 @@ module.exports = exports = function (path, fd, cb) {
|
||||
return Errors.toCallback(cb, msg.error())
|
||||
}
|
||||
|
||||
console.log('[/RELEASE]')
|
||||
return process.nextTick(cb, 0)
|
||||
})
|
||||
)
|
||||
|
||||
@@ -10,9 +10,9 @@ module.exports = exports = async function (path, fd, buffer, length, position, c
|
||||
console.log({socket_uuid, node_uuid})
|
||||
|
||||
const streamer = new Streamer(socket_uuid, node_uuid, length, position)
|
||||
streamer.write(buffer)
|
||||
|
||||
return process.nextTick(cb, length)
|
||||
streamer.write(buffer).then(() => {
|
||||
return process.nextTick(cb, length)
|
||||
})
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user