Small fixes
This commit is contained in:
@@ -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() {
|
func (t *TorrentManager) repairAll() {
|
||||||
proceed := t.canCapacityHandle() // blocks for approx 45 minutes if active torrents are full
|
proceed := t.canCapacityHandle() // blocks for approx 45 minutes if active torrents are full
|
||||||
if !proceed {
|
if !proceed {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package version
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
BuiltAt string = ""
|
BuiltAt string = ""
|
||||||
GoVersion string = "docker image inspect ghcr.io/debridmediamanager/zurg-testing | grep Id"
|
GoVersion string = ""
|
||||||
GitCommit string = ""
|
GitCommit string = "docker image inspect ghcr.io/debridmediamanager/zurg-testing | grep Id"
|
||||||
Version string = "docker"
|
Version string = "docker"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user