Skip to content

Commit c8ad8b0

Browse files
fix: resolve Windows updater file lock and release v1.1.6
1 parent aa122cd commit c8ad8b0

6 files changed

Lines changed: 20 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.6]
9+
10+
### Fixed
11+
- **Windows Updater**: Resolved a critical issue where the binary update would fail due to file locking. The process now ensures a clean handover between the main application and the update helper.
12+
813
## [1.1.5]
914

1015
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ kairo update
106106
```
107107

108108
Downloads the latest GitHub Release for your OS/arch, verifies it against `checksums.txt`, and safely replaces the installed binary.
109-
On Windows, the update is applied after `kairo update` exits; run `kairo` again once it completes.
109+
On Windows, Kairo will automatically close to apply the update; simply re-run `kairo` once the terminal returns.
110110

111111
---
112112

VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.5
1+
1.1.6

internal/lua/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (e *Engine) SetupKairoAPI(L *lua.LState) {
5555
L.SetField(kairo, "notify", L.NewFunction(e.luaNotify))
5656

5757
// Meta
58-
L.SetField(kairo, "version", lua.LString("1.1.5"))
58+
L.SetField(kairo, "version", lua.LString("1.1.6"))
5959

6060
// Set as global
6161
L.SetGlobal("kairo", kairo)

internal/updater/updater.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,14 @@ func applyWindows(target, backup, newBinPath string, stdout, stderr io.Writer) e
239239
}
240240

241241
cmd := exec.Command(helper, args...)
242-
cmd.Stdout = stdout
243-
cmd.Stderr = stderr
244-
242+
// On Windows, we need to detach or at least not wait for it.
243+
// We'll use os.StartProcess style via cmd.Start() but then we MUST exit.
245244
if err := cmd.Start(); err != nil {
246245
return err
247246
}
248247

249248
_, _ = fmt.Fprintln(stdout, "Update staged. Closing to finish update...")
249+
os.Exit(0)
250250
return nil
251251
}
252252

internal/updater/windows_helper.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,19 @@ func MaybeRunWindowsApply(stdout, stderr io.Writer) (handled bool, err error) {
3737
*backup = *target + ".old"
3838
}
3939

40-
_, _ = fmt.Fprintln(stdout, "Finishing update...")
41-
if err := applyWithRetry(*target, *backup, *source, 45*time.Second); err != nil {
42-
return true, err
40+
// Give parent process time to exit
41+
time.Sleep(1 * time.Second)
42+
43+
if err := applyWithRetry(*target, *backup, *source, 30*time.Second); err != nil {
44+
// Since we're in a detached-like process, we might want to log to a file
45+
// but for now, we'll try to use stderr if it's still connected.
46+
return true, fmt.Errorf("failed to apply update: %w", err)
4347
}
4448

4549
_ = os.Remove(*source)
50+
// We don't necessarily need to delete ourselves if we're in a temp dir,
51+
// but it's cleaner.
4652
scheduleSelfDelete()
47-
_, _ = fmt.Fprintln(stdout, "✓ Update applied. Re-run `kairo`.")
4853
return true, nil
4954
}
5055

0 commit comments

Comments
 (0)