mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user