fix checksum issue

This commit is contained in:
Ben Sarmiento
2023-10-20 04:37:43 +02:00
parent f1717a8d94
commit 7010803e35
4 changed files with 13 additions and 12 deletions

View File

@@ -73,10 +73,11 @@ func NewTorrentManager(config config.ConfigInterface) *TorrentManager {
func (t *TorrentManager) getChecksum() string {
torrents, totalCount, err := realdebrid.GetTorrents(t.token, 1)
if err != nil {
log.Printf("Cannot get torrents: %v\n", err.Error())
log.Printf("Cannot get torrents: %v\n", err)
return t.checksum
}
if len(torrents) == 0 {
log.Println("Huh, no torrents returned")
return t.checksum
}
return fmt.Sprintf("%d-%s", totalCount, torrents[0].ID)
@@ -87,7 +88,7 @@ func (t *TorrentManager) getAll() []Torrent {
torrents, totalCount, err := realdebrid.GetTorrents(t.token, 0)
if err != nil {
log.Printf("Cannot get torrents: %v\n", err.Error())
log.Printf("Cannot get torrents: %v\n", err)
return nil
}
t.checksum = fmt.Sprintf("%d-%s", totalCount, torrents[0].ID)
@@ -148,10 +149,10 @@ func (t *TorrentManager) RefreshInfo(torrentID string) {
}
err = os.Remove(filePath)
if err != nil && !os.IsNotExist(err) { // File doesn't exist or other error
log.Printf("Cannot remove file: %v\n", err.Error())
log.Printf("Cannot remove file: %v\n", err)
}
} else if !os.IsNotExist(err) { // Error other than file not existing
log.Printf("Error checking file info: %v\n", err.Error())
log.Printf("Error checking file info: %v\n", err)
return
}
info := t.getInfo(torrentID)
@@ -170,7 +171,7 @@ func (t *TorrentManager) getInfo(torrentID string) *Torrent {
log.Println("Getting info for", torrentID)
info, err := realdebrid.GetTorrentInfo(t.token, torrentID)
if err != nil {
log.Printf("Cannot get info: %v\n", err.Error())
log.Printf("Cannot get info: %v\n", err)
return nil
}
var selectedFiles []File