Failure case for latest state

This commit is contained in:
Ben Adrian Sarmiento
2024-07-12 16:09:04 +02:00
parent e81a000625
commit 0f0bdfcb5a

View File

@@ -38,19 +38,22 @@ func (t *TorrentManager) getCurrentState() LibraryState {
torrents, totalCount, err := t.rd.GetTorrents(true)
if err != nil {
t.log.Errorf("Checksum API Error (GetTorrents): %v", err)
return LibraryState{}
}
state.TotalCount = totalCount
if len(torrents) > 0 {
state.FirstTorrentId = torrents[0].ID
state.TotalCount = t.latestState.TotalCount
state.FirstTorrentId = t.latestState.FirstTorrentId
} else {
state.TotalCount = totalCount
if len(torrents) > 0 {
state.FirstTorrentId = torrents[0].ID
}
}
count, err := t.rd.GetActiveTorrentCount()
if err != nil {
t.log.Errorf("Checksum API Error (GetActiveTorrentCount): %v", err)
return LibraryState{}
state.ActiveCount = t.latestState.ActiveCount
} else {
state.ActiveCount = count.DownloadingCount
}
state.ActiveCount = count.DownloadingCount
return state
}