ssh2-scp 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,45 +10,7 @@ class SshFs {
10
10
  this.session = session;
11
11
  }
12
12
  async detectChunkSize() {
13
- if (this._chunkSize !== null) {
14
- return this._chunkSize;
15
- }
16
- const parseMemKb = (kb) => {
17
- if (kb > 256 * 1024) {
18
- return 4 * 1024;
19
- } else if (kb > 128 * 1024) {
20
- return 2 * 1024;
21
- } else if (kb > 64 * 1024) {
22
- return 1 * 1024;
23
- }
24
- return 512;
25
- };
26
- try {
27
- const output = await this.runCmd("free -b");
28
- const lines = output.trim().split("\n");
29
- const memLine = lines.find((l) => l.startsWith("Mem:"));
30
- if (memLine) {
31
- const parts = memLine.trim().split(/\s+/);
32
- const totalMemKb = parseInt(parts[1], 10);
33
- this._chunkSize = parseMemKb(totalMemKb);
34
- return this._chunkSize;
35
- }
36
- } catch (err) {
37
- console.error("[ssh-fs] detectChunkSize: free -b failed", err);
38
- }
39
- try {
40
- const output = await this.runCmd("cat /proc/meminfo");
41
- const memTotalLine = output.split("\n").find((l) => l.startsWith("MemTotal:"));
42
- if (memTotalLine) {
43
- const kb = parseInt(memTotalLine.split(":")[1].trim(), 10);
44
- this._chunkSize = parseMemKb(kb);
45
- return this._chunkSize;
46
- }
47
- } catch (err) {
48
- console.error("[ssh-fs] detectChunkSize: /proc/meminfo failed", err);
49
- }
50
- this._chunkSize = 1 * 1024;
51
- console.error("[ssh-fs] detectChunkSize: using default chunkSize");
13
+ this._chunkSize = 4 * 1024;
52
14
  return this._chunkSize;
53
15
  }
54
16
  getExecOpts() {
@@ -8,45 +8,7 @@ class SshFs {
8
8
  this.session = session;
9
9
  }
10
10
  async detectChunkSize() {
11
- if (this._chunkSize !== null) {
12
- return this._chunkSize;
13
- }
14
- const parseMemKb = (kb) => {
15
- if (kb > 256 * 1024) {
16
- return 4 * 1024;
17
- } else if (kb > 128 * 1024) {
18
- return 2 * 1024;
19
- } else if (kb > 64 * 1024) {
20
- return 1 * 1024;
21
- }
22
- return 512;
23
- };
24
- try {
25
- const output = await this.runCmd("free -b");
26
- const lines = output.trim().split("\n");
27
- const memLine = lines.find((l) => l.startsWith("Mem:"));
28
- if (memLine) {
29
- const parts = memLine.trim().split(/\s+/);
30
- const totalMemKb = parseInt(parts[1], 10);
31
- this._chunkSize = parseMemKb(totalMemKb);
32
- return this._chunkSize;
33
- }
34
- } catch (err) {
35
- console.error("[ssh-fs] detectChunkSize: free -b failed", err);
36
- }
37
- try {
38
- const output = await this.runCmd("cat /proc/meminfo");
39
- const memTotalLine = output.split("\n").find((l) => l.startsWith("MemTotal:"));
40
- if (memTotalLine) {
41
- const kb = parseInt(memTotalLine.split(":")[1].trim(), 10);
42
- this._chunkSize = parseMemKb(kb);
43
- return this._chunkSize;
44
- }
45
- } catch (err) {
46
- console.error("[ssh-fs] detectChunkSize: /proc/meminfo failed", err);
47
- }
48
- this._chunkSize = 1 * 1024;
49
- console.error("[ssh-fs] detectChunkSize: using default chunkSize");
11
+ this._chunkSize = 4 * 1024;
50
12
  return this._chunkSize;
51
13
  }
52
14
  getExecOpts() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh2-scp",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Remote file system operations over SSH2 session without SFTP",
5
5
  "scripts": {
6
6
  "build": "npm run build:esm && npm run build:cjs",
@@ -8,7 +8,8 @@
8
8
  "build:cjs": "vite build --config build/vite.config.cjs.ts --outDir dist/cjs",
9
9
  "test": "node test/ssh2-fs.test.mjs && node test/transfer.test.mjs",
10
10
  "lint": "echo \"Lint not configured\" && exit 0",
11
- "typecheck": "tsc --noEmit"
11
+ "typecheck": "tsc --noEmit",
12
+ "bench": "node benchmark/benchmark.js"
12
13
  },
13
14
  "homepage": "https://github.com/electerm/ssh2-scp#readme",
14
15
  "bugs": {
@@ -56,4 +57,4 @@
56
57
  "engines": {
57
58
  "node": ">=22.0.0"
58
59
  }
59
- }
60
+ }