mirror of
https://github.com/MetaCubeX/Clash.Meta.git
synced 2025-04-18 08:20:53 +00:00
once do
This commit is contained in:
parent
a595606ccb
commit
ffb783ab9c
1 changed files with 2 additions and 1 deletions
|
@ -19,13 +19,14 @@ import (
|
|||
|
||||
type bodyWrapper struct {
|
||||
io.ReadCloser
|
||||
once sync.Once
|
||||
onHitEOF func()
|
||||
}
|
||||
|
||||
func (b *bodyWrapper) Read(p []byte) (n int, err error) {
|
||||
n, err = b.ReadCloser.Read(p)
|
||||
if err == io.EOF && b.onHitEOF != nil {
|
||||
b.onHitEOF()
|
||||
b.once.Do(b.onHitEOF)
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue