mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
fix crash on preload
This commit is contained in:
@@ -81,6 +81,18 @@ func (b *BufferPool) ReleaseBuffer(index int) {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BufferPool) Used() map[int]struct{} {
|
||||
used := make(map[int]struct{})
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
for _, b := range b.buffs {
|
||||
if b.used {
|
||||
used[b.pieceId] = struct{}{}
|
||||
}
|
||||
}
|
||||
return used
|
||||
}
|
||||
|
||||
func (b *BufferPool) Len() int {
|
||||
return b.frees
|
||||
}
|
||||
|
||||
@@ -149,12 +149,7 @@ func (c *Cache) getRemPieces() []*Piece {
|
||||
pieces := make([]*Piece, 0)
|
||||
fill := int64(0)
|
||||
loading := 0
|
||||
used := make(map[int]struct{})
|
||||
for _, b := range c.bufferPull.buffs {
|
||||
if b.used {
|
||||
used[b.pieceId] = struct{}{}
|
||||
}
|
||||
}
|
||||
used := c.bufferPull.Used()
|
||||
for u := range used {
|
||||
v := c.pieces[u]
|
||||
if v.Size > 0 {
|
||||
|
||||
Reference in New Issue
Block a user