Skip to content

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.

test(windows): allow cold notification runtime startup

baiyuzecd15ab0bce60
diff --git a/client-core/go.mod b/client-core/go.mod
index 3f0baa7..249dff3 100644
--- a/client-core/go.mod
+++ b/client-core/go.mod
@@ -6,7 +6,6 @@ require modernc.org/sqlite v1.59.0
require (
github.com/dustin/go-humanize v1.0.1 // indirect
- github.com/godbus/dbus/v5 v5.2.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
diff --git a/client-core/internal/notifications/windows.go b/client-core/internal/notifications/windows.go
index da548df..ae38c23 100644
--- a/client-core/internal/notifications/windows.go
+++ b/client-core/internal/notifications/windows.go
@@ -93,7 +93,10 @@ func powershell(ctx context.Context, script string) ([]byte, error) {
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
output, err := cmd.CombinedOutput()
if err != nil {
- return nil, fmt.Errorf("Windows notification: %w", err)
+ if ctx.Err() != nil {
+ return nil, fmt.Errorf("Windows notification: %w", ctx.Err())
+ }
+ return nil, fmt.Errorf("Windows notification: %w: %s", err, bytes.TrimSpace(output))
}
return output, nil
}
diff --git a/client-core/internal/notifications/windows_test.go b/client-core/internal/notifications/windows_test.go
index b828ab8..544b568 100644
--- a/client-core/internal/notifications/windows_test.go
+++ b/client-core/internal/notifications/windows_test.go
@@ -13,7 +13,7 @@ import (
)
func TestWindowsNativeToastXML(t *testing.T) {
- ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
+ ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
markup := base64.StdEncoding.EncodeToString([]byte(toastXML(Message{ID: "test", Title: "Receive", Body: `<file & name>`, Action: "receive", ActionLabel: "Receive"})))
output, err := powershell(ctx, toastPrelude+`$xml=New-Object Windows.Data.Xml.Dom.XmlDocument; $xml.LoadXml([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('`+markup+`'))); [Windows.UI.Notifications.ToastNotification]::new($xml).Content.GetXml()`)