Merge branch 'master' into 230-torrents-category

This commit is contained in:
cocool97
2024-03-24 14:28:31 +01:00
committed by GitHub
64 changed files with 1437 additions and 508 deletions

View File

@@ -6,6 +6,8 @@ import (
"sync"
"time"
utils2 "server/utils"
"github.com/anacrolix/torrent"
"github.com/anacrolix/torrent/metainfo"
@@ -266,7 +268,10 @@ func (t *Torrent) drop() {
}
}
func (t *Torrent) Close() {
func (t *Torrent) Close() bool {
if t.cache != nil && t.cache.GetUseReaders() > 0 {
return false
}
t.Stat = state.TorrentClosed
t.bt.mu.Lock()
@@ -274,6 +279,7 @@ func (t *Torrent) Close() {
t.bt.mu.Unlock()
t.drop()
return true
}
func (t *Torrent) Status() *state.TorrentStatus {
@@ -329,7 +335,7 @@ func (t *Torrent) Status() *state.TorrentStatus {
files := t.Files()
sort.Slice(files, func(i, j int) bool {
return files[i].Path() < files[j].Path()
return utils2.CompareStrings(files[i].Path(), files[j].Path())
})
for i, f := range files {
st.FileStats = append(st.FileStats, &state.TorrentFileStat{