move auto-update to later (#603)
otherwise on windows the settings path (which is based on userData) isn't available yet.
This commit is contained in:
47
src/main.ts
47
src/main.ts
@@ -16,6 +16,7 @@ import { handleDyadProReturn } from "./main/pro";
|
||||
import { IS_TEST_BUILD } from "./ipc/utils/test_utils";
|
||||
import { BackupManager } from "./backup_manager";
|
||||
import { getDatabasePath, initializeDatabase } from "./db";
|
||||
import { UserSettings } from "./lib/schemas";
|
||||
|
||||
log.errorHandler.startCatching();
|
||||
log.eventLogger.startLogging();
|
||||
@@ -23,24 +24,6 @@ log.scope.labelPadding = false;
|
||||
|
||||
const logger = log.scope("main");
|
||||
|
||||
// Check settings before enabling auto-update
|
||||
const settings = readSettings();
|
||||
if (settings.enableAutoUpdate) {
|
||||
// Technically we could just pass the releaseChannel directly to the host,
|
||||
// but this is more explicit and falls back to stable if there's an unknown
|
||||
// release channel.
|
||||
const postfix = settings.releaseChannel === "beta" ? "beta" : "stable";
|
||||
const host = `https://api.dyad.sh/v1/update/${postfix}`;
|
||||
updateElectronApp({
|
||||
logger,
|
||||
updateSource: {
|
||||
type: UpdateSourceType.ElectronPublicUpdateService,
|
||||
repo: "dyad-sh/dyad",
|
||||
host,
|
||||
},
|
||||
}); // additional configuration options available
|
||||
}
|
||||
|
||||
// Load environment variables from .env file
|
||||
dotenv.config();
|
||||
|
||||
@@ -74,16 +57,30 @@ export async function onReady() {
|
||||
logger.error("Error initializing backup manager", e);
|
||||
}
|
||||
initializeDatabase();
|
||||
await onFirstRunMaybe();
|
||||
const settings = readSettings();
|
||||
await onFirstRunMaybe(settings);
|
||||
createWindow();
|
||||
|
||||
logger.info("Auto-update enabled=", settings.enableAutoUpdate);
|
||||
if (settings.enableAutoUpdate) {
|
||||
// Technically we could just pass the releaseChannel directly to the host,
|
||||
// but this is more explicit and falls back to stable if there's an unknown
|
||||
// release channel.
|
||||
const postfix = settings.releaseChannel === "beta" ? "beta" : "stable";
|
||||
const host = `https://api.dyad.sh/v1/update/${postfix}`;
|
||||
logger.info("Auto-update release channel=", postfix);
|
||||
updateElectronApp({
|
||||
logger,
|
||||
updateSource: {
|
||||
type: UpdateSourceType.ElectronPublicUpdateService,
|
||||
repo: "dyad-sh/dyad",
|
||||
host,
|
||||
},
|
||||
}); // additional configuration options available
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this the first run of Fiddle? If so, perform
|
||||
* tasks that we only want to do in this case.
|
||||
*/
|
||||
export async function onFirstRunMaybe() {
|
||||
const settings = readSettings();
|
||||
export async function onFirstRunMaybe(settings: UserSettings) {
|
||||
if (!settings.hasRunBefore) {
|
||||
await promptMoveToApplicationsFolder();
|
||||
writeSettings({
|
||||
|
||||
Reference in New Issue
Block a user