Small fixes

This commit is contained in:
Ben Sarmiento
2023-12-03 11:20:23 +01:00
parent 3c9d4079f5
commit 5bf102b1be
2 changed files with 2 additions and 64 deletions

View File

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

View File

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