Skip to content

Commit 6fc2883

Browse files
committed
Adjust update for windows.
1 parent 0ca2dc5 commit 6fc2883

4 files changed

Lines changed: 19 additions & 10 deletions

File tree

cmd/rawrequest-updater/updater_main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,11 @@ func dief(format string, args ...any) {
173173
}
174174

175175
func installParentDir(installPath string) string {
176-
if strings.HasSuffix(strings.ToLower(installPath), ".app") {
177-
return filepath.Dir(installPath)
176+
parent := filepath.Dir(installPath)
177+
if parent == "" {
178+
return installPath
178179
}
179-
return installPath
180+
return parent
180181
}
181182

182183
func ensureDirWritable(dir string) error {

frontend/src/app/components/update-notification/update-notification.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ export class UpdateNotificationComponent {
1313
protected updateService = inject(UpdateService);
1414

1515
async downloadOrRestart(): Promise<void> {
16+
// Capture before the call — if the update is already downloaded, the Go
17+
// side will launch the updater helper and quit the app. The Wails runtime
18+
// teardown will sever the RPC channel, causing the await to reject. That
19+
// rejection is expected and must not trigger the browser-open fallback.
20+
const isRestart = this.updateService.isUpdateReady();
21+
1622
const started = await this.updateService.startUpdateAndRestart();
17-
if (!started) {
23+
if (!started && !isRestart) {
1824
await this.updateService.openReleasePage();
19-
this.updateService.remindLater();
25+
this.updateService.remindLater();
2026
}
2127
}
2228

internal/updateapplylogic/install_parent.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import (
77
)
88

99
func InstallParentDir(installPath string) (string, error) {
10-
parent := installPath
11-
if strings.HasSuffix(strings.ToLower(strings.TrimSpace(installPath)), ".app") {
12-
parent = filepath.Dir(installPath)
10+
trimmed := strings.TrimSpace(installPath)
11+
if trimmed == "" {
12+
return "", errors.New("could not determine install parent directory")
1313
}
14-
if strings.TrimSpace(parent) == "" {
14+
parent := filepath.Dir(trimmed)
15+
if parent == "" || parent == trimmed {
1516
return "", errors.New("could not determine install parent directory")
1617
}
1718
return parent, nil

internal/updateapplylogic/install_parent_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ func TestInstallParentDir(t *testing.T) {
1010
wantErr string
1111
}{
1212
{name: "empty", path: "", want: "", wantErr: "could not determine install parent directory"},
13-
{name: "regular path", path: "/Applications/RawRequest", want: "/Applications/RawRequest", wantErr: ""},
13+
{name: "regular path", path: "/Applications/RawRequest", want: "/Applications", wantErr: ""},
1414
{name: "app bundle", path: "/Applications/RawRequest.app", want: "/Applications", wantErr: ""},
1515
{name: "app bundle case-insensitive", path: "/Applications/RawRequest.APP", want: "/Applications", wantErr: ""},
16+
{name: "windows install dir", path: "C:/Apps/RawRequest", want: "C:/Apps", wantErr: ""},
1617
}
1718

1819
for _, tt := range tests {

0 commit comments

Comments
 (0)