pinokiod 8.2.20 → 8.2.21

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.
@@ -273,6 +273,11 @@ report_errors: false`)
273
273
  await caddy.stop()
274
274
  }
275
275
 
276
+ if (this.kernel.anywhere) {
277
+ ondata({ raw: `stopping Pinokio Anywhere before replacing Miniforge...\r\n` })
278
+ await this.kernel.anywhere.stop()
279
+ }
280
+
276
281
  legacy_path_exists = await this.kernel.exists(`bin/${LEGACY_CONDA_ROOT_DIR}`)
277
282
  if (legacy_path_exists) {
278
283
  console.log("Removing legacy install path...", legacy_path)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "8.2.20",
3
+ "version": "8.2.21",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -471,6 +471,65 @@ test('Conda replacement stops a running managed Caddy without restoring it', asy
471
471
  assert.equal(caddyRunning, false)
472
472
  })
473
473
 
474
+ test('Conda replacement waits for Anywhere shutdown before deleting either runtime', async t => {
475
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), 'pinokio-conda-anywhere-stop-'))
476
+ t.after(() => fs.rm(root, { recursive: true, force: true }))
477
+ const miniforge = await createMiniforge(root)
478
+ const miniconda = await createLegacyMiniconda(root)
479
+ const kernel = createKernel(root, 'win32')
480
+ let finishStop
481
+ let enteredStop
482
+ const stopping = new Promise(resolve => { enteredStop = resolve })
483
+ const stopped = new Promise(resolve => { finishStop = resolve })
484
+ kernel.anywhere = { stop: async () => { enteredStop(); await stopped } }
485
+ kernel.bin.mods = []
486
+ kernel.bin.download = async () => {}
487
+ kernel.bin.rm = async () => {}
488
+ let bootstrapped = false
489
+ kernel.bin.exec = async payload => {
490
+ if (payload.conda?.skip) {
491
+ bootstrapped = true
492
+ assert.equal(await pathExists(miniforge), false)
493
+ assert.equal(await pathExists(miniconda), false)
494
+ await fs.mkdir(path.join(miniforge, 'conda-meta'), { recursive: true })
495
+ await fs.writeFile(path.join(miniforge, 'python.exe'), 'fake python\n')
496
+ }
497
+ }
498
+
499
+ const conda = createConda(kernel)
500
+ const installing = conda._install({ dependencies: [] }, () => {})
501
+ try {
502
+ await stopping
503
+ await new Promise(setImmediate)
504
+ assert.equal(await pathExists(path.join(miniforge, 'Scripts/conda.exe')), true)
505
+ assert.equal(await pathExists(path.join(miniconda, 'Scripts/conda.exe')), true)
506
+ assert.equal(bootstrapped, false)
507
+ } finally {
508
+ finishStop()
509
+ await installing
510
+ }
511
+ assert.equal(bootstrapped, true)
512
+ })
513
+
514
+ test('Conda replacement preserves both runtimes when Anywhere shutdown fails', async t => {
515
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), 'pinokio-conda-anywhere-failure-'))
516
+ t.after(() => fs.rm(root, { recursive: true, force: true }))
517
+ const miniforge = await createMiniforge(root)
518
+ const miniconda = await createLegacyMiniconda(root)
519
+ const kernel = createKernel(root, 'win32')
520
+ const failure = new Error('tailscaled did not stop')
521
+ kernel.anywhere = { stop: async () => { throw failure } }
522
+ kernel.bin.download = async () => {}
523
+ kernel.bin.exec = async () => assert.fail('installer must not run after shutdown failure')
524
+ const conda = createConda(kernel)
525
+ conda.removeInstallPath = async () => assert.fail('runtime deletion must not start after shutdown failure')
526
+
527
+ await assert.rejects(conda._install({ dependencies: [] }, () => {}), error => error === failure)
528
+
529
+ assert.equal(await fs.readFile(path.join(miniforge, 'Scripts/conda.exe'), 'utf8'), 'fake conda\n')
530
+ assert.equal(await fs.readFile(path.join(miniconda, 'Scripts/conda.exe'), 'utf8'), 'fake conda\n')
531
+ })
532
+
474
533
  test('Conda install replaces legacy miniconda with a compatibility alias to miniforge', async () => {
475
534
  const root = await fs.mkdtemp(path.join(os.tmpdir(), 'pinokio-conda-miniforge-alias-'))
476
535
  const legacy = await createLegacyMiniconda(root)