Failure case for latest state
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user