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): show small file sizes in notifications as KB or bytes
baiyuze1facb13a8147
diff --git a/client-core/internal/notifications/notifications.go b/client-core/internal/notifications/notifications.goindex b13f713..7906f82 100644--- a/client-core/internal/notifications/notifications.go+++ b/client-core/internal/notifications/notifications.go@@ -352,8 +352,13 @@ func translate(lang, key string) string {return catalog["en"][key]}func humanSize(n int64) string {- if n >= 1<<30 {+ switch {+ case n >= 1<<30:return fmt.Sprintf("%.1f GB", float64(n)/(1<<30))+ case n >= 1<<20:+ return fmt.Sprintf("%.1f MB", float64(n)/(1<<20))+ case n >= 1<<10:+ return fmt.Sprintf("%.0f KB", float64(n)/(1<<10))}- return fmt.Sprintf("%.1f MB", float64(n)/(1<<20))+ return fmt.Sprintf("%d B", n)}diff --git a/client-core/internal/notifications/notifications_test.go b/client-core/internal/notifications/notifications_test.goindex c6f353c..2a6592f 100644--- a/client-core/internal/notifications/notifications_test.go+++ b/client-core/internal/notifications/notifications_test.go@@ -90,6 +90,14 @@ func TestNativeCatalogHasEveryLocaleAndPlaceholder(t *testing.T) {}}+func TestHumanSize(t *testing.T) {+ for n, want := range map[int64]string{5: "5 B", 2048: "2 KB", 3 << 20: "3.0 MB", 5 << 30: "5.0 GB"} {+ if got := humanSize(n); got != want {+ t.Errorf("humanSize(%d) = %q,应当是 %q", n, got, want)+ }+ }+}+func TestWindowsToastEscapesFilenamesAndKeepsFullActionIdentity(t *testing.T) {n := Message{ID: "full-id/with spaces?&", Title: `<receive & paste>`, Body: `a"b & <file>`, Action: "receive", ActionLabel: `Receive "file"`}markup := toastXML(n)