hope finally fix rewind

This commit is contained in:
nikk gitanes
2021-08-22 18:55:28 +03:00
parent 56fe672571
commit f8014e9853
4 changed files with 12 additions and 12 deletions

View File

@@ -1,7 +1,6 @@
package torr
import (
"fmt"
"io"
"io/ioutil"
"os"
@@ -102,7 +101,7 @@ func GetTorrent(hashHex string) *Torrent {
go func() {
lockApi.Lock()
defer lockApi.Unlock()
fmt.Println("Add torrent")
log.TLogln("Add torrent")
tr, _ := NewTorrent(tor.TorrentSpec, bts)
if tr != nil {
tr.Title = tor.Title
@@ -215,15 +214,15 @@ func SetSettings(set *sets.BTSets) {
}
lockApi.Lock()
defer lockApi.Unlock()
fmt.Println("drop all")
log.TLogln("drop all")
dropAllTorrent()
time.Sleep(time.Second * 2)
fmt.Println("disconect")
log.TLogln("disconect")
bts.Disconnect()
sets.SetBTSets(set)
fmt.Println("connect")
log.TLogln("connect")
bts.Connect()
fmt.Println("end set settings")
log.TLogln("end set settings")
}
func SetDefSettings() {

View File

@@ -199,6 +199,7 @@ func (c *Cache) cleanPieces() {
rems := (c.filled-c.capacity)/c.pieceLength + 1
for _, p := range remPieces {
c.removePiece(p)
c.torrent.Piece(p.Id).UpdateCompletion()
rems--
if rems <= 0 {
utils.FreeOSMemGC()
@@ -239,7 +240,7 @@ func (c *Cache) getRemPieces() []*Piece {
}
}
c.updatePriority()
c.clearPriority()
c.muReaders.Lock()
for r, _ := range c.readers {
@@ -328,10 +329,10 @@ func (c *Cache) CloseReader(r *Reader) {
r.Close()
delete(r.cache.readers, r)
r.cache.muReaders.Unlock()
go c.updatePriority()
go c.clearPriority()
}
func (c *Cache) updatePriority() {
func (c *Cache) clearPriority() {
time.Sleep(time.Second)
ranges := make([]Range, 0)
c.muReaders.Lock()