Skip to content

Commit

Permalink
Remove desktop config before reinstall
Browse files Browse the repository at this point in the history
  • Loading branch information
webfiltered committed Dec 25, 2024
1 parent 8a0dfe1 commit 660cc21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main-process/comfyDesktopApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ComfySettings } from '../config/comfySettings';
import { AppWindow } from './appWindow';
import { ComfyServer } from './comfyServer';
import { ComfyServerConfig } from '../config/comfyServerConfig';
import fs from 'node:fs';
import { type ElectronContextMenuOptions } from '../preload';
import path from 'node:path';
import { ansiCodes, getModelsDirectory } from '../utils';
Expand All @@ -18,6 +17,7 @@ import { Terminal } from '../shell/terminal';
import { DesktopConfig, useDesktopConfig } from '../store/desktopConfig';
import { restoreCustomNodes } from '../services/backup';
import { CmCli } from '../services/cmCli';
import { rm } from 'node:fs/promises';

export class ComfyDesktopApp {
public comfyServer: ComfyServer | null = null;
Expand Down Expand Up @@ -116,10 +116,9 @@ export class ComfyDesktopApp {
ipcMain.handle(IPC_CHANNELS.IS_FIRST_TIME_SETUP, () => {
return !ComfyServerConfig.exists();
});
// eslint-disable-next-line @typescript-eslint/require-await
ipcMain.handle(IPC_CHANNELS.REINSTALL, async () => {
log.info('Reinstalling...');
this.reinstall();
await this.reinstall();
});
type SentryErrorDetail = {
error: string;
Expand Down Expand Up @@ -238,12 +237,13 @@ export class ComfyDesktopApp {
return new ComfyDesktopApp(basePath, new ComfySettings(basePath), appWindow);
}

uninstall(): void {
fs.rmSync(ComfyServerConfig.configPath);
async uninstall(): Promise<void> {
await rm(ComfyServerConfig.configPath);
await useDesktopConfig().permanentlyDeleteConfigFile();
}

reinstall(): void {
this.uninstall();
async reinstall(): Promise<void> {
await this.uninstall();
this.restart();
}

Expand Down
4 changes: 4 additions & 0 deletions src/store/desktopConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class DesktopConfig {
this.#store.delete(key);
}

async permanentlyDeleteConfigFile() {
await fs.rm(path.join(app.getPath('userData'), 'config.json'));
}

/**
* Static factory method. Loads the config from disk.
* @param shell Shell environment that can open file and folder views for the user
Expand Down

0 comments on commit 660cc21

Please sign in to comment.