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): tell detailed-logging sessions apart by count, not end time
baiyuze782696491d56
diff --git a/client-core/cmd/copysyncd/verbose.go b/client-core/cmd/copysyncd/verbose.goindex d42732c..522d3cc 100644--- a/client-core/cmd/copysyncd/verbose.go+++ b/client-core/cmd/copysyncd/verbose.go@@ -16,6 +16,7 @@ type verboseLog struct {base slog.Level // 关回去时的级别:用 -v 启动的一直是 Debuguntil time.Timetimer *time.Timer+ session int // 每打开一次加一,计时器据此认出自己是不是这一轮的changed func() // 打开、关闭时调用,让界面刷新状态}@@ -26,6 +27,7 @@ func (v *verboseLog) Set(d time.Duration) time.Time {v.timer.Stop()v.timer = nil}+ v.session++if d <= 0 {v.until = time.Time{}logLevel.Set(v.base)@@ -35,7 +37,8 @@ func (v *verboseLog) Set(d time.Duration) time.Time {v.until = untillogLevel.Set(slog.LevelDebug)slog.Info("详细日志已打开", "到", until.Format("15:04:05"))- v.timer = time.AfterFunc(d, func() { v.expire(until) })+ session := v.session+ v.timer = time.AfterFunc(d, func() { v.expire(session) })}until := v.untilv.mu.Unlock()@@ -45,10 +48,11 @@ func (v *verboseLog) Set(d time.Duration) time.Time {return until}-// expire 是计时器到点后的关闭。期间用户又打开过一次的话,until 已经变了,这次到点不算数-func (v *verboseLog) expire(until time.Time) {+// expire 是计时器到点后的关闭。期间用户又打开或关闭过的话,这次到点不算数。+// 不按截止时间比较:Windows 的时钟精度粗,连着打开两次,两次的截止时间可能一模一样+func (v *verboseLog) expire(session int) {v.mu.Lock()- current := v.until.Equal(until)+ current := v.session == sessionv.mu.Unlock()if current {v.Set(0)diff --git a/client-core/cmd/copysyncd/verbose_test.go b/client-core/cmd/copysyncd/verbose_test.goindex 6bd4306..11b5e9f 100644--- a/client-core/cmd/copysyncd/verbose_test.go+++ b/client-core/cmd/copysyncd/verbose_test.go@@ -25,8 +25,10 @@ func TestVerboseLog(t *testing.T) {t.Fatalf("到点后没有关闭:level=%v until=%v", logLevel.Level(), v.Until())}- // 上一轮的计时器晚到一步,不能把刚刚重新打开的详细日志关掉- old := v.Set(time.Hour)+ // 上一轮的计时器晚到一步,不能把刚刚重新打开的详细日志关掉。+ // 两次紧挨着打开,在 Windows 上截止时间可能相同,所以按第几轮来认+ v.Set(time.Hour)+ old := v.sessionv.Set(time.Hour)v.expire(old)if logLevel.Level() != slog.LevelDebug || v.Until().IsZero() {