adjustments

This commit is contained in:
Ben Sarmiento
2024-02-16 05:47:53 +01:00
parent 945be6066d
commit 255fbfe976
5 changed files with 13 additions and 12 deletions

View File

@@ -137,14 +137,16 @@ func (t *TorrentManager) StartRefreshJob() {
// getMoreInfo gets original name, size and files for a torrent
func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
if torrentFromCache, exists := infoCache.Get(rdTorrent.ID); exists &&
!torrentFromCache.AnyInProgress() &&
torrentFromCache.SelectedFiles.Count() == len(rdTorrent.Links) {
return torrentFromCache
} else if !exists {
torrentFromFile := t.readTorrentFromFile(rdTorrent.ID)
if torrentFromFile != nil &&
!torrentFromFile.AnyInProgress() &&
torrentFromFile.SelectedFiles.Count() == len(rdTorrent.Links) {
hasBrokenFiles := false
@@ -158,8 +160,7 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
infoCache.Set(rdTorrent.ID, torrentFromFile)
t.ResetSelectedFiles(torrentFromFile)
return torrentFromFile
} else {
t.log.Warnf("Torrent %s has broken files, will not save on info cache", rdTorrent.ID)
}
}
}
@@ -225,8 +226,11 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
torrent.InProgressIDs.Add(info.ID)
}
infoCache.Set(rdTorrent.ID, &torrent)
t.saveTorrentChangesToDisk(&torrent, nil)
// save to cache if it's not in progress anymore
if info.Progress == 100 {
infoCache.Set(rdTorrent.ID, &torrent)
t.saveTorrentChangesToDisk(&torrent, nil)
}
return &torrent
}