From 5bf102b1be755b65548cea628b3b4bb6fb2a2e2d Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Sun, 3 Dec 2023 11:20:23 +0100 Subject: [PATCH] Small fixes --- internal/torrent/manager.go | 62 ------------------------------------- internal/version/version.go | 4 +-- 2 files changed, 2 insertions(+), 64 deletions(-) diff --git a/internal/torrent/manager.go b/internal/torrent/manager.go index 658f494..256061d 100644 --- a/internal/torrent/manager.go +++ b/internal/torrent/manager.go @@ -493,68 +493,6 @@ func (t *TorrentManager) deleteTorrentFile(torrentID string) { } } -func (t *TorrentManager) organizeChaos(links []string, selectedFiles []*File) ([]*File, bool) { - type Result struct { - Response *realdebrid.Download - } - - resultsChan := make(chan Result, len(links)) - var wg sync.WaitGroup - - for _, link := range links { - wg.Add(1) - link := link // redeclare to avoid closure on loop variable - // Use the existing worker pool to submit tasks - _ = t.workerPool.Submit(func() { - defer wg.Done() - if t.DownloadCache.Has(link) { - download, _ := t.DownloadCache.Get(link) - resultsChan <- Result{Response: download} - return - } - resp := t.UnrestrictUntilOk(link) - resultsChan <- Result{Response: resp} - }) - } - - wg.Wait() - close(resultsChan) - - chaoticFileCount := 0 - for result := range resultsChan { - if result.Response == nil { - continue - } - found := false - for _, file := range selectedFiles { - if strings.Contains(file.Path, result.Response.Filename) { - file.Link = result.Response.Link - found = true - } - } - if !found { - if result.Response.Streamable == 1 { - now := time.Now().Format(time.RFC3339) - selectedFiles = append(selectedFiles, &File{ - File: realdebrid.File{ - ID: math.MaxInt32, - Path: result.Response.Filename, - Bytes: result.Response.Filesize, - Selected: 1, - }, - Added: now, - Ended: now, - Link: result.Response.Link, - }) - } else { - chaoticFileCount++ - } - } - } - - return selectedFiles, chaoticFileCount == len(links) -} - func (t *TorrentManager) repairAll() { proceed := t.canCapacityHandle() // blocks for approx 45 minutes if active torrents are full if !proceed { diff --git a/internal/version/version.go b/internal/version/version.go index 779a5fa..c9dc5b5 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -2,8 +2,8 @@ package version var ( BuiltAt string = "" - GoVersion string = "docker image inspect ghcr.io/debridmediamanager/zurg-testing | grep Id" - GitCommit string = "" + GoVersion string = "" + GitCommit string = "docker image inspect ghcr.io/debridmediamanager/zurg-testing | grep Id" Version string = "docker" )