Skip to content

Commit d9f2c4b

Browse files
authored
fix: unmount iso after install (#315)
* fix: unmount iso after install * add reset option for replacing compose and refresh state
1 parent 41133d8 commit d9f2c4b

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

src/renderer/lib/install.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ref, type Ref } from "vue";
55
import { createLogger } from "../utils/log";
66
import { createNanoEvents, type Emitter } from "nanoevents";
77
import { PortManager } from "../utils/port";
8+
import { Winboat } from "./winboat";
89
const fs: typeof import('fs') = require('fs');
910
const { exec }: typeof import('child_process') = require('child_process');
1011
const path: typeof import('path') = require('path');
@@ -306,6 +307,16 @@ export class InstallManager {
306307
if (res.status === 200) {
307308
logger.info("WinBoat Guest Server is up and healthy!");
308309
this.changeState(InstallStates.COMPLETED);
310+
311+
const winboat = new Winboat();
312+
const config = winboat.parseCompose();
313+
const filteredVolumes = config.services.windows.volumes.filter(volume => !volume.endsWith('/boot.iso'));
314+
315+
if (config.services.windows.volumes.length !== filteredVolumes.length) {
316+
config.services.windows.volumes = filteredVolumes;
317+
await winboat.replaceCompose(config, false);
318+
}
319+
309320
return;
310321
}
311322
// Log every 60 seconds (every 12th attempt with 5-second intervals)

src/renderer/lib/winboat.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -562,22 +562,20 @@ export class Winboat {
562562
this.containerActionLoading.value = false;
563563
}
564564

565-
async replaceCompose(composeConfig: ComposeConfig) {
565+
async replaceCompose(composeConfig: ComposeConfig, restart=true) {
566566
logger.info("Going to replace compose config");
567567
this.containerActionLoading.value = true;
568568

569569
const composeFilePath = path.join(WINBOAT_DIR, 'docker-compose.yml');
570-
571-
// 0. Stop the current container if it's online
572-
if (this.containerStatus.value === ContainerStatus.Running) {
573-
await this.stopContainer();
570+
571+
if (restart) {
572+
// 1. Compose down the current container
573+
await execAsync(`docker compose -f ${composeFilePath} down`);
574574
}
575575

576-
// 1. Compose down the current container
577-
await execAsync(`docker compose -f ${composeFilePath} down`);
578-
579576
// 2. Create a backup directory if it doesn't exist
580577
const backupDir = path.join(WINBOAT_DIR, 'backup');
578+
581579
if (!fs.existsSync(backupDir)) {
582580
fs.mkdirSync(backupDir);
583581
logger.info(`Created compose backup dir: ${backupDir}`)
@@ -592,10 +590,13 @@ export class Winboat {
592590
const newComposeYAML = PrettyYAML.stringify(composeConfig).replaceAll("null", "");
593591
fs.writeFileSync(composeFilePath, newComposeYAML, { encoding: 'utf8' });
594592
logger.info(`Wrote new compose file to: ${composeFilePath}`);
595-
596-
// 5. Deploy the container with the new compose file
597-
await execAsync(`docker compose -f ${composeFilePath} up -d`);
598-
593+
594+
if (restart) {
595+
// 5. Deploy the container with the new compose file
596+
await execAsync(`docker compose -f ${composeFilePath} up -d`);
597+
remote.getCurrentWindow().reload();
598+
}
599+
599600
logger.info("Replace compose config completed, successfully deployed new container");
600601

601602
this.containerActionLoading.value = false;

0 commit comments

Comments
 (0)