Clear download and unrestrict maps

This commit is contained in:
Ben Adrian Sarmiento
2024-07-11 16:50:22 +02:00
parent b0363edbbb
commit b9699c8a3e
2 changed files with 4 additions and 6 deletions

View File

@@ -381,6 +381,10 @@ func (t *TorrentManager) mountNewDownloads() {
token := t.Config.GetToken()
tokenMap, _ := t.rd.UnrestrictMap.Get(token)
// clear maps
tokenMap.Clear()
t.DownloadMap.Clear()
downloads := t.rd.GetDownloads()
mountedCount := 0
for i := range downloads {
@@ -426,10 +430,8 @@ func (t *TorrentManager) StartDownloadsJob() {
for {
select {
case <-remountTicker.C:
t.DownloadMap.Clear()
t.mountNewDownloads()
case <-t.RemountTrigger:
t.DownloadMap.Clear()
t.mountNewDownloads()
}
}

View File

@@ -82,8 +82,6 @@ func (rd *RealDebrid) UnrestrictAndVerify(link string) (*Download, error) {
if utils.IsBytesLimitReached(err) {
rd.TokenManager.SetTokenAsExpired(token, "bandwidth limit exceeded")
continue
} else if utils.IsInvalidDownloadCode(err) {
continue
} else if err == nil {
rd.verifiedLinks.Set(download.ID, time.Now().Unix()+DOWNLOAD_LINK_EXPIRY)
return download, nil
@@ -103,8 +101,6 @@ func (rd *RealDebrid) UnrestrictAndVerify(link string) (*Download, error) {
if utils.IsBytesLimitReached(err) {
rd.TokenManager.SetTokenAsExpired(token, "bandwidth limit exceeded")
continue
} else if utils.IsInvalidDownloadCode(err) {
continue
} else if err != nil {
return nil, err
}