fix(189pc): transfer rename (#7958)

* fix(189pc): transfer rename

* fix: OverwriteUpload

* fix: change search method

* fix

* fix
This commit is contained in:
foxxorcat
2025-02-16 12:21:34 +08:00
committed by GitHub
parent 36b4204623
commit 399336b33c
4 changed files with 201 additions and 127 deletions

View File

@ -34,31 +34,36 @@ func NewDebounce2(interval time.Duration, f func()) func() {
if timer == nil {
timer = time.AfterFunc(interval, f)
}
(*time.Timer)(timer).Reset(interval)
timer.Reset(interval)
}
}
func NewThrottle(interval time.Duration) func(func()) {
var lastCall time.Time
var lock sync.Mutex
return func(fn func()) {
lock.Lock()
defer lock.Unlock()
now := time.Now()
if now.Sub(lastCall) < interval {
return
if now.Sub(lastCall) >= interval {
lastCall = now
go fn()
}
time.AfterFunc(interval, fn)
lastCall = now
}
}
func NewThrottle2(interval time.Duration, fn func()) func() {
var lastCall time.Time
var lock sync.Mutex
return func() {
lock.Lock()
defer lock.Unlock()
now := time.Now()
if now.Sub(lastCall) < interval {
return
if now.Sub(lastCall) >= interval {
lastCall = now
go fn()
}
time.AfterFunc(interval, fn)
lastCall = now
}
}