fix: show helpful message when Windows upgrade fails due to locked binary

When another process (e.g. `skillshare ui`) holds the exe file open,
Windows denies the rename. Detect this and suggest closing other
skillshare processes instead of showing a raw "Access is denied" error.
This commit is contained in:
Willie
2026-02-08 17:45:18 +08:00
parent 86b5650fe5
commit 3e8aec74aa
+4
View File
@@ -5,6 +5,7 @@ import (
"archive/zip"
"bytes"
"compress/gzip"
"errors"
"fmt"
"io"
"net/http"
@@ -331,6 +332,9 @@ func writeBinary(r io.Reader, destPath string) error {
// Rename running exe to .old
if err := os.Rename(destPath, oldPath); err != nil {
os.Remove(tmpPath)
if errors.Is(err, os.ErrPermission) {
return fmt.Errorf("binary is locked by another process (is 'skillshare ui' running?)\n Close other skillshare processes and try again")
}
return fmt.Errorf("failed to rename current binary: %w", err)
}
// Rename new exe to correct name