chore: keep original file permissions after update

This commit is contained in:
xishang0128 2025-07-25 23:32:29 +09:00
parent 8cbae59d55
commit 748b5df902
No known key found for this signature in database
GPG Key ID: 02DAB1BEA331D06C

View File

@ -73,7 +73,7 @@ func (u *CoreUpdater) Update(currentExePath string) (err error) {
u.mu.Lock() u.mu.Lock()
defer u.mu.Unlock() defer u.mu.Unlock()
_, err = os.Stat(currentExePath) info, err := os.Stat(currentExePath)
if err != nil { if err != nil {
return fmt.Errorf("check currentExePath %q: %w", currentExePath, err) return fmt.Errorf("check currentExePath %q: %w", currentExePath, err)
} }
@ -146,6 +146,8 @@ func (u *CoreUpdater) Update(currentExePath string) (err error) {
return fmt.Errorf("backuping: %w", err) return fmt.Errorf("backuping: %w", err)
} }
_ = os.Chmod(updateExePath, info.Mode())
err = u.replace(updateExePath, currentExePath) err = u.replace(updateExePath, currentExePath)
if err != nil { if err != nil {
return fmt.Errorf("replacing: %w", err) return fmt.Errorf("replacing: %w", err)