Last minute fixes

This commit is contained in:
Ben Sarmiento
2023-11-21 19:17:36 +01:00
parent 81d1629c8c
commit fa41c81082
4 changed files with 12 additions and 12 deletions

View File

@@ -339,13 +339,11 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
var err error
// file cache
torrentFromFile := t.readFromFile(rdTorrent.ID)
if torrentFromFile != nil && len(torrentFromFile.ID) > 0 && len(torrentFromFile.Links) == len(rdTorrent.Links) {
if (len(torrentFromFile.Links) > 0 && torrentFromFile.Links[0] == rdTorrent.Links[0]) || len(torrentFromFile.Links) == 0 {
// see if api data and file data still match
// then it means data is still usable
info = torrentFromFile
info.Progress = rdTorrent.Progress
}
if torrentFromFile != nil && len(torrentFromFile.ID) > 0 && len(torrentFromFile.Links) > 0 && len(torrentFromFile.Links) == len(rdTorrent.Links) && torrentFromFile.Links[0] == rdTorrent.Links[0] {
info = torrentFromFile
info.Progress = rdTorrent.Progress
} else {
torrentFromFile = nil
}
if info == nil {
info, err = t.api.GetTorrentInfo(rdTorrent.ID)
@@ -390,6 +388,7 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
for _, file := range selectedFiles {
torrent.SelectedFiles.Set(filepath.Base(file.Path), file)
}
if len(selectedFiles) > 0 && torrentFromFile == nil {
t.writeToFile(info) // only when there are selected files, else it's useless
}