Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

Update stats.go

Cette révision appartient à :
kilo 2017-11-24 12:49:39 +01:00 révisé par GitHub
Parent 81ef4b92d9
révision ec3858e304
Signature inconnue de Forgejo
ID de la clé GPG: 4AEE18F83AFDEB23
1 fichiers modifiés avec 5 ajouts et 2 suppressions

Voir le fichier

@ -27,7 +27,7 @@ func initClient() error {
DHTConfig: dht.ServerConfig{
StartingNodes: dht.GlobalBootstrapAddrs,
},
ListenAddr: ":5977",
ListenAddr: ":" + strconv.Itoa(config.Get().Torrents.FilesFetchingClientPort),
}
cl, err := torrent.NewClient(&clientConfig)
if err != nil {
@ -124,7 +124,7 @@ func UpdateTorrentStats(torrent *models.Torrent, stats goscrape.Result, currentS
torrent.Scrape.Update(false)
}
if len(Files) > 0 {
if len(Files) > 1 {
files, err := torrent.CreateFileList(Files)
if err != nil {
@ -143,6 +143,9 @@ func UpdateTorrentStats(torrent *models.Torrent, stats goscrape.Result, currentS
slice.Sort(JSONFilelist, func(i, j int) bool {
return strings.ToLower(JSONFilelist[i].Path) < strings.ToLower(JSONFilelist[j].Path)
})
} else if len(Files) == 1 {
torrent.Filesize = Files[0].Length()
torrent.Update(false)
}
return