fix(startup): a launch that fails before the window says why
Reported from a Windows 10 machine: the process appears, no data folder is created, nothing starts. There was nothing to read because the only log OpsLog has lives inside the folder that was never created. Three exits happen before any window or log exists, and all three were silent. Another instance already running — correct to refuse, since two would fight over the rig, but indistinguishable from a crash. The data folder unwritable — it is created BESIDE the executable, so a copy dropped into Program Files is refused by Windows outright. And wails.Run failing, which is where a missing WebView2 runtime lands; its error went to println, which in a GUI-subsystem program goes nowhere at all. Each now writes to %LOCALAPPDATA%\OpsLog\startup.log — a folder Windows guarantees the user can write to, whatever OpsLog was installed into — and shows a message box naming the fault and what to do about it.
This commit is contained in:
@@ -87,8 +87,27 @@ func main() {
|
||||
// A --post-update relaunch (from the auto-updater) may start while the previous
|
||||
// instance is still exiting and holding the single-instance mutex — wait for it
|
||||
// to free instead of bailing out. Then clear the old exe it left behind.
|
||||
bootLogLaunch()
|
||||
postUpdate := hasFlag(os.Args[1:], "--post-update")
|
||||
if !acquireInstance(postUpdate) {
|
||||
// SAID, not merely done. This exit is correct — a second instance would
|
||||
// fight the first over the rig — but it happened in total silence: no
|
||||
// window, no data folder, no log, which is indistinguishable from a
|
||||
// program that died on its first instruction.
|
||||
bootLog("another instance already holds the single-instance mutex - exiting")
|
||||
fatalBox("OpsLog", "OpsLog is already running.\n\nLook for its window, or for a leftover OpsLog.exe in the Task Manager, and close it before starting another.")
|
||||
return
|
||||
}
|
||||
bootLog("single-instance mutex acquired")
|
||||
|
||||
// The data folder is created BESIDE the executable, so a copy dropped into
|
||||
// Program Files is refused the write by Windows — and that refusal ended the
|
||||
// launch with nothing on screen and nothing in any file, since the only log
|
||||
// OpsLog had was inside the folder it could not create.
|
||||
if err := checkDataDirWritable(); err != nil {
|
||||
bootLog("FATAL %v", err)
|
||||
fatalBox("OpsLog", "OpsLog cannot write next to its own program file.\n\n"+err.Error()+
|
||||
"\n\nMove OpsLog.exe somewhere your account can write — a folder in Documents, or the desktop — and start it again. Program Files is refused to anything not running as administrator.")
|
||||
return
|
||||
}
|
||||
if postUpdate {
|
||||
@@ -150,6 +169,11 @@ func main() {
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
// The last thing that can fail before a window exists, and the most
|
||||
// opaque of them: a missing WebView2 runtime lands here. println goes
|
||||
// nowhere in a GUI-subsystem program, so this went unseen and unlogged.
|
||||
bootLog("FATAL wails.Run: %v", err)
|
||||
fatalBox("OpsLog", "OpsLog could not open its window.\n\n"+err.Error()+
|
||||
"\n\nThis is usually a missing WebView2 runtime — install \"Microsoft Edge WebView2 Runtime\" and try again.")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user