Fixes on merge behavior; remove downloads cap

This commit is contained in:
Ben Adrian Sarmiento
2024-06-04 23:58:56 +02:00
parent b0d05d27d4
commit f977abc052
5 changed files with 15 additions and 35 deletions

View File

@@ -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()

View File

@@ -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