21 lines
769 B
JavaScript
21 lines
769 B
JavaScript
const Fuse = require('fuse-native')
|
|
const Errors = require('../../shared/Errors')
|
|
const Message = require('../../shared/Message')
|
|
const connector = require('../connector')
|
|
const Streamer = require('../Streamer')
|
|
|
|
module.exports = exports = async function (path, fd, buffer, length, position, cb) {
|
|
try {
|
|
const { socket_uuid, node_uuid } = await connector.simple_request('stream.getfd', { descriptor: fd })
|
|
|
|
const streamer = new Streamer(socket_uuid, node_uuid, length, position)
|
|
const stream_buffer = await streamer.buffer()
|
|
|
|
if ( stream_buffer.length < 1 ) return process.nextTick(cb, 0)
|
|
stream_buffer.copy(buffer)
|
|
return process.nextTick(cb, stream_buffer.length)
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
}
|