Fixes on merge behavior; remove downloads cap
This commit is contained in:
@@ -30,7 +30,6 @@ type ConfigInterface interface {
|
||||
GetRateLimitSleepSecs() int
|
||||
ShouldDeleteRarFiles() bool
|
||||
GetDownloadsEveryMins() int
|
||||
GetDownloadsLimit() int
|
||||
GetDumpTorrentsEveryMins() int
|
||||
GetPlayableExtensions() []string
|
||||
GetTorrentsCount() int
|
||||
@@ -117,35 +116,28 @@ func (z *ZurgConfig) GetNumOfWorkers() int {
|
||||
|
||||
func (z *ZurgConfig) GetRefreshEverySecs() int {
|
||||
if z.RefreshEverySecs == 0 {
|
||||
return 60
|
||||
return 15
|
||||
}
|
||||
return z.RefreshEverySecs
|
||||
}
|
||||
|
||||
func (z *ZurgConfig) GetRepairEveryMins() int {
|
||||
if z.RepairEveryMins == 0 {
|
||||
return 60
|
||||
return 60 // 1 hour
|
||||
}
|
||||
return z.RepairEveryMins
|
||||
}
|
||||
|
||||
func (z *ZurgConfig) GetDownloadsEveryMins() int {
|
||||
if z.DownloadsEveryMins == 0 {
|
||||
return 1440
|
||||
return 720 // 12 hours
|
||||
}
|
||||
return z.DownloadsEveryMins
|
||||
}
|
||||
|
||||
func (z *ZurgConfig) GetDownloadsLimit() int {
|
||||
if z.DownloadsLimit == 0 {
|
||||
return 10000
|
||||
}
|
||||
return z.DownloadsLimit
|
||||
}
|
||||
|
||||
func (z *ZurgConfig) GetDumpTorrentsEveryMins() int {
|
||||
if z.DumpTorrentsEveryMins == 0 {
|
||||
return 1440
|
||||
return 1440 // 1 day
|
||||
}
|
||||
return z.DumpTorrentsEveryMins
|
||||
}
|
||||
@@ -226,7 +218,7 @@ func (z *ZurgConfig) GetPlayableExtensions() []string {
|
||||
|
||||
func (z *ZurgConfig) GetTorrentsCount() int {
|
||||
if z.TorrentsCount == 0 {
|
||||
return 100
|
||||
return 250
|
||||
}
|
||||
return z.TorrentsCount
|
||||
}
|
||||
|
||||
@@ -222,10 +222,6 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
||||
<td>Refresh Download Mount Every...</td>
|
||||
<td>%d mins</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Get downloads limit</td>
|
||||
<td>%d items</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Dump Torrents Every...</td>
|
||||
<td>%d mins</td>
|
||||
@@ -336,7 +332,6 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
||||
response.Config.GetTorrentsCount(),
|
||||
response.Config.GetDownloadTimeoutSecs(),
|
||||
response.Config.GetDownloadsEveryMins(),
|
||||
response.Config.GetDownloadsLimit(),
|
||||
response.Config.GetDumpTorrentsEveryMins(),
|
||||
response.Config.GetRateLimitSleepSecs(),
|
||||
response.Config.GetRetriesUntilFailed(),
|
||||
|
||||
@@ -342,12 +342,10 @@ func (t *TorrentManager) mountNewDownloads() {
|
||||
downloads := t.api.GetDownloads()
|
||||
for i := range downloads {
|
||||
isRealDebrid := strings.HasPrefix(downloads[i].Link, "https://real-debrid.com/d/")
|
||||
if isRealDebrid && !t.UnrestrictMap.Has(downloads[i].Link[0:39]) {
|
||||
t.UnrestrictMap.Set(downloads[i].Link[0:39], &downloads[i])
|
||||
} else if !isRealDebrid {
|
||||
if !t.UnrestrictMap.Has(downloads[i].Link) {
|
||||
t.UnrestrictMap.Set(downloads[i].Link, &downloads[i])
|
||||
}
|
||||
if isRealDebrid {
|
||||
t.UnrestrictMap.SetIfAbsent(downloads[i].Link[0:39], &downloads[i])
|
||||
} else {
|
||||
t.UnrestrictMap.SetIfAbsent(downloads[i].Link, &downloads[i])
|
||||
filename := filepath.Base(downloads[i].Filename)
|
||||
t.DownloadMap.Set(filename, &downloads[i])
|
||||
}
|
||||
@@ -362,6 +360,7 @@ func (t *TorrentManager) StartDownloadsJob() {
|
||||
for {
|
||||
select {
|
||||
case <-remountTicker.C:
|
||||
t.DownloadMap.Clear()
|
||||
t.mountNewDownloads()
|
||||
case <-t.RemountTrigger:
|
||||
t.DownloadMap.Clear()
|
||||
|
||||
@@ -296,9 +296,7 @@ func (t *TorrentManager) mergeTorrents(existing, toMerge *Torrent) *Torrent {
|
||||
// selected files
|
||||
mergedTorrent.SelectedFiles = cmap.New[*File]()
|
||||
newer.SelectedFiles.IterCb(func(key string, file *File) {
|
||||
if f, ok := mergedTorrent.SelectedFiles.Get(key); !ok || !f.State.Is("ok_file") {
|
||||
mergedTorrent.SelectedFiles.Set(key, file)
|
||||
}
|
||||
mergedTorrent.SelectedFiles.SetIfAbsent(key, file)
|
||||
})
|
||||
older.SelectedFiles.IterCb(func(key string, file *File) {
|
||||
mediaInfo := file.MediaInfo
|
||||
|
||||
@@ -194,6 +194,7 @@ func (rd *RealDebrid) GetTorrents(onlyOne bool) ([]Torrent, int, error) {
|
||||
for i := 0; i < maxParallelThreads; i++ {
|
||||
res := <-allResults
|
||||
if res.err != nil {
|
||||
rd.log.Warnf("Ignoring error when fetching torrents: %v", res.err)
|
||||
continue
|
||||
}
|
||||
allTorrents = append(allTorrents, res.torrents...)
|
||||
@@ -362,8 +363,6 @@ func (rd *RealDebrid) GetDownloads() []Download {
|
||||
return nil
|
||||
}
|
||||
|
||||
maxItems := rd.cfg.GetDownloadsLimit()
|
||||
|
||||
// reset allDownloads
|
||||
allDownloads := []Download{}
|
||||
page := 1
|
||||
@@ -401,18 +400,15 @@ func (rd *RealDebrid) GetDownloads() []Download {
|
||||
res := <-allResults
|
||||
err := <-errChan
|
||||
if err != nil {
|
||||
return allDownloads
|
||||
rd.log.Warnf("Ignoring error when fetching downloads: %v", err)
|
||||
continue
|
||||
}
|
||||
allDownloads = append(allDownloads, res...)
|
||||
}
|
||||
|
||||
rd.log.Debugf("Got %d/%d downloads", len(allDownloads), totalCount)
|
||||
|
||||
if len(allDownloads) >= totalCount || page >= maxPages || len(allDownloads) >= maxItems {
|
||||
if len(allDownloads) > maxItems {
|
||||
rd.log.Debugf("Capping it to %d downloads", len(allDownloads))
|
||||
allDownloads = allDownloads[:maxItems]
|
||||
}
|
||||
if len(allDownloads) >= totalCount || page >= maxPages {
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user