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) torrents, totalCount, err := t.rd.GetTorrents(true)
if err != nil { if err != nil {
t.log.Errorf("Checksum API Error (GetTorrents): %v", err) t.log.Errorf("Checksum API Error (GetTorrents): %v", err)
return LibraryState{} state.TotalCount = t.latestState.TotalCount
} state.FirstTorrentId = t.latestState.FirstTorrentId
state.TotalCount = totalCount } else {
if len(torrents) > 0 { state.TotalCount = totalCount
state.FirstTorrentId = torrents[0].ID if len(torrents) > 0 {
state.FirstTorrentId = torrents[0].ID
}
} }
count, err := t.rd.GetActiveTorrentCount() count, err := t.rd.GetActiveTorrentCount()
if err != nil { if err != nil {
t.log.Errorf("Checksum API Error (GetActiveTorrentCount): %v", err) 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 return state
} }