mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-19 06:43:42 +00:00
fix: download panic
This commit is contained in:
1 parent
b0bd2a776a
commit
753830accf
9 files changed
+181
-67
No files matched your search
@@ -1,8 +1,9 @@
|
||||
package torrent
|
||||
|
||||
import (
|
||||
"github.com/RoaringBitmap/roaring"
|
||||
"sync"
|
||||
|
||||
"github.com/RoaringBitmap/roaring"
|
||||
)
|
||||
|
||||
type state int
|
||||
@@ -62,6 +63,18 @@ func (ps *pieces) getReady() int {
|
||||
return -1
|
||||
}
|
||||
|
||||
func (ps *pieces) getLeft() int {
|
||||
ps.rw.RLock()
|
||||
defer ps.rw.RUnlock()
|
||||
count := 0
|
||||
for _, s := range ps.arr {
|
||||
if s.state != stateFinished {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func (ps *pieces) size() int {
|
||||
return len(ps.arr)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user