increased r/w buffer size
This commit is contained in:
@@ -3,6 +3,7 @@ import { Uint64BE } from 'int64-buffer';
|
||||
|
||||
import file from '../io/file';
|
||||
import packet from '../networking/packet';
|
||||
import { RW_BUFFER_SIZE } from '../utils/constants';
|
||||
|
||||
const _snapshot_directory = async (conn, remote_path) => {
|
||||
try {
|
||||
@@ -218,7 +219,7 @@ export const download_file = async (
|
||||
|
||||
let remain = src_size - offset;
|
||||
while (remain > 0) {
|
||||
const to_write = remain >= 65536 ? 65536 : remain;
|
||||
const to_write = remain >= RW_BUFFER_SIZE ? RW_BUFFER_SIZE : remain;
|
||||
const buffer = await src.read(offset, to_write);
|
||||
const written = fs.writeSync(dst_fd, buffer, 0, to_write, offset);
|
||||
if (written > 0) {
|
||||
@@ -531,7 +532,7 @@ export const upload_file = async (
|
||||
}
|
||||
|
||||
let remain = src_st.size - offset;
|
||||
const default_buffer = Buffer.alloc(65536 * 2);
|
||||
const default_buffer = Buffer.alloc(RW_BUFFER_SIZE);
|
||||
while (remain > 0) {
|
||||
const to_write =
|
||||
remain >= default_buffer.length ? default_buffer.length : remain;
|
||||
|
||||
@@ -14,3 +14,4 @@ export const setCustomEncryption = (ce) => {
|
||||
export const instance_id = uuidv4();
|
||||
export const package_json = _package_json;
|
||||
export const get_version = () => _package_json.version;
|
||||
export const RW_BUFFER_SIZE = 1024 * 1024;
|
||||
|
||||
Reference in New Issue
Block a user