Merge remote-tracking branch 'origin/master'

This commit is contained in:
YouROK
2021-08-21 16:00:52 +03:00
25 changed files with 117 additions and 166 deletions

View File

@@ -8,6 +8,8 @@ import (
"sync"
"time"
"github.com/anacrolix/torrent"
"server/log"
"server/settings"
)
@@ -82,4 +84,6 @@ func (p *DiskPiece) Release() {
p.piece.Complete = false
os.Remove(p.name)
p.piece.cache.torrent.Piece(p.piece.Id).SetPriority(torrent.PiecePriorityNone)
}

View File

@@ -4,6 +4,8 @@ import (
"io"
"sync"
"time"
"github.com/anacrolix/torrent"
)
type MemPiece struct {
@@ -67,4 +69,6 @@ func (p *MemPiece) Release() {
}
p.piece.Size = 0
p.piece.Complete = false
p.piece.cache.torrent.Piece(p.piece.Id).SetPriority(torrent.PiecePriorityNone)
}

View File

@@ -1,9 +1,7 @@
package torrstor
import (
"github.com/anacrolix/torrent"
"github.com/anacrolix/torrent/storage"
"server/settings"
)
@@ -75,10 +73,9 @@ func (p *Piece) Release() {
} else {
p.dPiece.Release()
}
if !p.cache.isClosed {
p.cache.torrent.Piece(p.Id).SetPriority(torrent.PiecePriorityNone)
// fix remove pieces hash
p.cache.torrent.Piece(p.Id).UpdateCompletion()
}
// if !p.cache.isClosed {
// p.cache.torrent.Piece(p.Id).SetPriority(torrent.PiecePriorityNone)
// // fix remove pieces hash
// p.cache.torrent.Piece(p.Id).UpdateCompletion()
// }
}

View File

@@ -30,11 +30,7 @@ func (s *Storage) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (stor
ch := NewCache(s.capacity, s)
ch.Init(info, infoHash)
s.caches[infoHash] = ch
//return ch, nil
return storage2.TorrentImpl{
Piece: ch.Piece,
Close: ch.Close,
}, nil
return ch, nil
}
func (s *Storage) CloseHash(hash metainfo.Hash) {