PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.
Dart airdrop-alternativeclipboardclipboard-sharingclipboard-synccopy-pastecross-platformend-to-end-encryptionfile-syncfile-transferfluttergolanglinuxmacosnat-traversalp2pself-hostedtailscaleuniversal-clipboardwebrtcwindows
fix(core): report a failed update without a service restart
baiyuze14bc2dd2ace0
diff --git a/client-core/internal/update/service.go b/client-core/internal/update/service.goindex 88f56b6..e75a99a 100644--- a/client-core/internal/update/service.go+++ b/client-core/internal/update/service.go@@ -41,6 +41,7 @@ type Service struct {lastAuto time.Timefiles map[string]string // 版本 → 已下载并校验过的安装包result *Result+ resultMod time.Time}// NewService 读出上一次安装的结果(如果有)。@@ -129,9 +130,13 @@ func (s *Service) Notice() string {}// LastResult 是刚完成的那次安装的结果,过了 resultFresh 就不再提。+// 安装失败时后台服务可能根本没被重启(比如没有获得管理员授权),所以结果文件变了就重新读。func (s *Service) LastResult() *Result {s.mu.Lock()defer s.mu.Unlock()+ if st, err := os.Stat(filepath.Join(s.Root, "updates", "result.json")); err == nil && !st.ModTime().Equal(s.resultMod) {+ s.result, s.resultMod = ReadResult(s.Root), st.ModTime()+ }if s.result == nil || time.Since(time.Unix(s.result.At, 0)) > resultFresh {return nil}diff --git a/client-core/internal/update/update_test.go b/client-core/internal/update/update_test.goindex b90f114..f8893d5 100644--- a/client-core/internal/update/update_test.go+++ b/client-core/internal/update/update_test.go@@ -353,6 +353,24 @@ func TestReadResultUntilStale(t *testing.T) {}}+// 安装失败、后台服务没被重启时,正在运行的服务也要能报告结果。+func TestServiceSeesResultWrittenWhileRunning(t *testing.T) {+ root := t.TempDir()+ s, err := NewService("2.3.0", root, slog.New(slog.NewTextHandler(io.Discard, nil)))+ if err != nil {+ t.Fatal(err)+ }+ if s.LastResult() != nil {+ t.Fatal("result before any update")+ }+ os.MkdirAll(filepath.Join(root, "updates"), 0o700)+ raw, _ := json.Marshal(Result{From: "2.3.0", To: "2.3.1", Error: "denied", At: time.Now().Unix()})+ os.WriteFile(filepath.Join(root, "updates", "result.json"), raw, 0o600)+ if r := s.LastResult(); r == nil || r.OK || r.Error != "denied" {+ t.Fatalf("result written while running: %+v", r)+ }+}+func TestPublicKeyIsValid(t *testing.T) {if len(PublicKeys()) == 0 {t.Fatal("no valid public key compiled in")