pinokiod 0.1.65 → 0.1.69

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.
@@ -2,10 +2,13 @@ const path = require('path')
2
2
  //const decompress = require('decompress');
3
3
  const fs = require("fs")
4
4
  const fse = require('fs-extra')
5
+ const { rimraf } = require('rimraf')
5
6
  const Pdrive = require('pdrive')
6
7
  const { DownloaderHelper } = require('node-downloader-helper');
7
8
  const randomUseragent = require('random-useragent');
8
9
  const symlinkDir = require('symlink-dir')
10
+ const retry = require('async-retry');
11
+
9
12
 
10
13
  class FS {
11
14
  async read(req, ondata, kernel) {
@@ -41,20 +44,35 @@ class FS {
41
44
  async share(req, ondata, kernel) {
42
45
  /////////////////////////////////////////////////////////////////////////////
43
46
  //
44
- // 1. 1:1 Drive mapping (1 file path per 1 drive folder)
45
- // {
46
- // “method”: “fs.share”,
47
- // “params”: {
48
- // "drive": {
49
- // “models/checkpoints": "app/models/checkpoints",
50
- // “models/vae": "app/models/VAE",
51
- // },
52
- // “peers”: [ “https://github.com/cocktailpeanut/comfyui.git" ]
47
+ // 1. peer to peer shared drive
48
+ //
49
+ // 1. 1:1 Drive mapping (1 file path per 1 drive folder)
50
+ // {
51
+ // “method”: “fs.share”,
52
+ // “params”: {
53
+ // "drive": {
54
+ // “models/checkpoints": "app/models/checkpoints",
55
+ // “models/vae": "app/models/VAE",
56
+ // },
57
+ // “peers”: [ “https://github.com/cocktailpeanut/comfyui.git" ]
58
+ // }
53
59
  // }
54
- // }
55
60
  //
56
61
  //
57
- // 2. 1:N Drive mapping (N file paths per 1 drive folder)
62
+ // 2. 1:N Drive mapping (N file paths per 1 drive folder)
63
+ // {
64
+ // “method”: “fs.share”,
65
+ // “params”: {
66
+ // "drive": {
67
+ // “models/checkpoints": "app/models/checkpoints",
68
+ // “models/loras": [ "app/models/Lora", "app/models/LyCORIS" ],
69
+ // },
70
+ // “peers”: [ “https://github.com/cocktailpeanut/comfyui.git" ]
71
+ // }
72
+ // }
73
+ //
74
+ // 2. centralized shared drive (for package registries)
75
+ //
58
76
  // {
59
77
  // “method”: “fs.share”,
60
78
  // “params”: {
@@ -62,12 +80,13 @@ class FS {
62
80
  // “models/checkpoints": "app/models/checkpoints",
63
81
  // “models/loras": [ "app/models/Lora", "app/models/LyCORIS" ],
64
82
  // },
65
- // “peers”: [ “https://github.com/cocktailpeanut/comfyui.git" ]
83
+ // “parent”: "pip"|"npm"|"github"
66
84
  // }
67
85
  // }
68
86
  //
69
87
  /////////////////////////////////////////////////////////////////////////////
70
88
 
89
+ console.log("fs.share", req.params)
71
90
 
72
91
  if (req.params.drive) {
73
92
  const drivePath = kernel.path("drive")
@@ -106,6 +125,7 @@ class FS {
106
125
 
107
126
  req.params.drive[route] = linkPath
108
127
  }
128
+ console.log("call drive.create")
109
129
  await drive.create({
110
130
  uri: req.parent.git,
111
131
  drive: req.params.drive,
@@ -121,7 +141,7 @@ class FS {
121
141
  let cwd = (req.cwd ? req.cwd : kernel.api.userdir)
122
142
  let filepath = path.resolve(cwd, req.params.path)
123
143
  // await fs.promises.rm(filepath)
124
- await fse.remove(filepath)
144
+ await rimraf(filepath)
125
145
  }
126
146
  async copy(req, ondata, kernel) {
127
147
  let cwd = (req.cwd ? req.cwd : kernel.api.userdir)
@@ -232,7 +252,7 @@ class FS {
232
252
  // append to the empty file
233
253
  await this.append(req, ondata, kernel)
234
254
  }
235
- async download (req, ondata, kernel) {
255
+ async _download(req, ondata, kernel) {
236
256
  /*
237
257
  params := {
238
258
  url,
@@ -257,12 +277,6 @@ class FS {
257
277
  headers: {
258
278
  "user-agent": userAgent,
259
279
  },
260
- httpRequestOptions: {
261
- timeout: 5000
262
- },
263
- httpsRequestOptions: {
264
- timeout: 5000
265
- },
266
280
  override: {
267
281
  skip: true,
268
282
  skipSmaller: false,
@@ -282,12 +296,6 @@ class FS {
282
296
  headers: {
283
297
  "user-agent": userAgent,
284
298
  },
285
- httpRequestOptions: {
286
- timeout: 5000
287
- },
288
- httpsRequestOptions: {
289
- timeout: 5000
290
- },
291
299
  override: {
292
300
  skip: true,
293
301
  skipSmaller: false,
@@ -359,6 +367,17 @@ class FS {
359
367
  reject(err)
360
368
  })
361
369
  })
370
+ }
371
+ async download (req, ondata, kernel) {
372
+ await retry(async (bail, number) => {
373
+ ondata({ raw: `\r\n[Attempt ${number}]` })
374
+ console.log("trying", number)
375
+ await this._download(req, ondata, kernel)
376
+ console.log("success")
377
+ }, {
378
+ retries: 10,
379
+ factor: 2
380
+ })
362
381
 
363
382
  }
364
383
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "0.1.65",
3
+ "version": "0.1.69",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,6 +10,7 @@
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "7zip-min-win-asar-support": "^1.4.4",
13
+ "async-retry": "^1.3.3",
13
14
  "axios": "^1.4.0",
14
15
  "clear-module": "^4.1.2",
15
16
  "compressing": "^1.10.0",
@@ -40,7 +41,7 @@
40
41
  "multer": "^1.4.5-lts.1",
41
42
  "node-downloader-helper": "^2.1.9",
42
43
  "node-pty-prebuilt-multiarch-cp": "^0.10.1-pre.48",
43
- "pdrive": "^0.0.12",
44
+ "pdrive": "^0.0.14",
44
45
  "portfinder": "^1.0.32",
45
46
  "random-useragent": "^0.5.0",
46
47
  "rimraf": "^5.0.0",