mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-20 14:06:09 +05:00
update
This commit is contained in:
@@ -65,6 +65,11 @@ func NewTorrent(spec *torrent.TorrentSpec, bt *BTServer) (*Torrent, error) {
|
||||
spec.Trackers = [][]string{utils.GetDefTrackers()}
|
||||
}
|
||||
|
||||
trackers := utils.GetTrackerFromFile()
|
||||
if len(trackers) > 0 {
|
||||
spec.Trackers = append(spec.Trackers, [][]string{trackers}...)
|
||||
}
|
||||
|
||||
goTorrent, _, err := bt.client.AddTorrentSpec(spec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -104,6 +109,7 @@ func (t *Torrent) WaitInfo() bool {
|
||||
case <-t.Torrent.GotInfo():
|
||||
t.cache = t.bt.storage.GetCache(t.Hash())
|
||||
t.cache.SetTorrent(t.Torrent)
|
||||
go t.cache.LoadPiecesOnDisk()
|
||||
return true
|
||||
case <-t.closed:
|
||||
return false
|
||||
@@ -167,7 +173,9 @@ func (t *Torrent) progressEvent() {
|
||||
t.BytesReadUsefulData = st.BytesRead.Int64()
|
||||
t.BytesWrittenData = st.BytesWritten.Int64()
|
||||
|
||||
t.PreloadedBytes = t.cache.GetState().Filled
|
||||
if t.cache != nil {
|
||||
t.PreloadedBytes = t.cache.GetState().Filled
|
||||
}
|
||||
} else {
|
||||
t.DownloadSpeed = 0
|
||||
t.UploadSpeed = 0
|
||||
@@ -352,9 +360,7 @@ func (t *Torrent) Close() {
|
||||
t.Stat = state.TorrentClosed
|
||||
|
||||
t.bt.mu.Lock()
|
||||
if _, ok := t.bt.torrents[t.Hash()]; ok {
|
||||
delete(t.bt.torrents, t.Hash())
|
||||
}
|
||||
delete(t.bt.torrents, t.Hash())
|
||||
t.bt.mu.Unlock()
|
||||
|
||||
t.drop()
|
||||
|
||||
Reference in New Issue
Block a user