pinokiod 0.1.66 → 0.1.70

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,46 @@ 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. With no peers
50
+ // {
51
+ // “method”: “fs.share”,
52
+ // “params”: {
53
+ // "drive": {
54
+ // “models/checkpoints": "app/models/checkpoints",
55
+ // “models/vae": "app/models/VAE",
56
+ // }
57
+ // }
58
+ // }
59
+ //
60
+ // 1.2. 1:1 Drive mapping (1 file path per 1 drive folder)
61
+ // {
62
+ // “method”: “fs.share”,
63
+ // “params”: {
64
+ // "drive": {
65
+ // “models/checkpoints": "app/models/checkpoints",
66
+ // “models/vae": "app/models/VAE",
67
+ // },
68
+ // “peers”: [ “https://github.com/cocktailpeanut/comfyui.git" ]
69
+ // }
53
70
  // }
54
- // }
55
71
  //
56
72
  //
57
- // 2. 1:N Drive mapping (N file paths per 1 drive folder)
73
+ // 1.3. 1:N Drive mapping (N file paths per 1 drive folder)
74
+ // {
75
+ // “method”: “fs.share”,
76
+ // “params”: {
77
+ // "drive": {
78
+ // “models/checkpoints": "app/models/checkpoints",
79
+ // “models/loras": [ "app/models/Lora", "app/models/LyCORIS" ],
80
+ // },
81
+ // “peers”: [ “https://github.com/cocktailpeanut/comfyui.git" ]
82
+ // }
83
+ // }
84
+ //
85
+ // 2. centralized shared drive (for package registries)
86
+ //
58
87
  // {
59
88
  // “method”: “fs.share”,
60
89
  // “params”: {
@@ -62,14 +91,18 @@ class FS {
62
91
  // “models/checkpoints": "app/models/checkpoints",
63
92
  // “models/loras": [ "app/models/Lora", "app/models/LyCORIS" ],
64
93
  // },
65
- // “peers”: [ “https://github.com/cocktailpeanut/comfyui.git" ]
94
+ // “parent”: "pip"|"npm"|"github"
66
95
  // }
67
96
  // }
68
97
  //
69
98
  /////////////////////////////////////////////////////////////////////////////
70
99
 
100
+ console.log("fs.share", req.params)
101
+
102
+ ondata({ raw: "\r\ncreating a shared drive:\r\n" + JSON.stringify(req.params, null, 2).replace(/\n/g, "\r\n") })
71
103
 
72
104
  if (req.params.drive) {
105
+ if (req.params.peers
73
106
  const drivePath = kernel.path("drive")
74
107
  const drive = new Pdrive(drivePath)
75
108
  for(const route in req.params.drive) {
@@ -106,6 +139,7 @@ class FS {
106
139
 
107
140
  req.params.drive[route] = linkPath
108
141
  }
142
+ console.log("call drive.create")
109
143
  await drive.create({
110
144
  uri: req.parent.git,
111
145
  drive: req.params.drive,
@@ -121,13 +155,15 @@ class FS {
121
155
  let cwd = (req.cwd ? req.cwd : kernel.api.userdir)
122
156
  let filepath = path.resolve(cwd, req.params.path)
123
157
  // await fs.promises.rm(filepath)
124
- await fse.remove(filepath)
158
+ ondata({ raw: "\r\nremoving:\r\n" + filepath + "\r\n" })
159
+ await rimraf(filepath)
125
160
  }
126
161
  async copy(req, ondata, kernel) {
127
162
  let cwd = (req.cwd ? req.cwd : kernel.api.userdir)
128
163
  let src = path.resolve(cwd, req.params.src)
129
164
  let dest = path.resolve(cwd, req.params.dest)
130
165
  let options = req.params.options
166
+ ondata({ raw: "\r\ncopying:\r\nfrom: " + src + "\r\nto: " + dest + "\r\n" })
131
167
  await fs.promises.cp(src, dest, options)
132
168
  }
133
169
 
@@ -232,7 +268,7 @@ class FS {
232
268
  // append to the empty file
233
269
  await this.append(req, ondata, kernel)
234
270
  }
235
- async download (req, ondata, kernel) {
271
+ async _download(req, ondata, kernel) {
236
272
  /*
237
273
  params := {
238
274
  url,
@@ -257,12 +293,6 @@ class FS {
257
293
  headers: {
258
294
  "user-agent": userAgent,
259
295
  },
260
- httpRequestOptions: {
261
- timeout: 80000
262
- },
263
- httpsRequestOptions: {
264
- timeout: 80000
265
- },
266
296
  override: {
267
297
  skip: true,
268
298
  skipSmaller: false,
@@ -282,12 +312,6 @@ class FS {
282
312
  headers: {
283
313
  "user-agent": userAgent,
284
314
  },
285
- httpRequestOptions: {
286
- timeout: 80000
287
- },
288
- httpsRequestOptions: {
289
- timeout: 80000
290
- },
291
315
  override: {
292
316
  skip: true,
293
317
  skipSmaller: false,
@@ -359,6 +383,17 @@ class FS {
359
383
  reject(err)
360
384
  })
361
385
  })
386
+ }
387
+ async download (req, ondata, kernel) {
388
+ await retry(async (bail, number) => {
389
+ ondata({ raw: `\r\n[Attempt ${number}]` })
390
+ console.log("trying", number)
391
+ await this._download(req, ondata, kernel)
392
+ console.log("success")
393
+ }, {
394
+ retries: 10,
395
+ factor: 2
396
+ })
362
397
 
363
398
  }
364
399
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "0.1.66",
3
+ "version": "0.1.70",
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",