Simplify bin

This commit is contained in:
Ben Adrian Sarmiento
2024-06-20 06:36:08 +02:00
parent bc04737ca7
commit 340735f833
4 changed files with 36 additions and 84 deletions

View File

@@ -38,13 +38,21 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
idx := i
t.workerPool.Submit(func() {
defer wg.Done()
if t.binOnceDoneErrorCheck(instances[idx].ID, instances[idx].Status) ||
instances[idx].Progress != 100 {
status := instances[idx].Status
if status != "downloading" && status != "downloaded" && status != "uploading" && status != "queued" && status != "compressing" && status != "waiting_files_selection" {
t.deleteOnceDone(instances[idx].ID, true)
}
if instances[idx].Progress != 100 {
mergeChan <- nil
return
}
tInfo := t.getMoreInfo(instances[idx])
if tInfo == nil {
// just in case!
mergeChan <- nil
return
}
torrent := t.convertToTorrent(tInfo)
accessKey := t.GetKey(torrent)
freshAccessKeys.Add(accessKey)
@@ -113,12 +121,11 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
t.getInfoFiles().Each(func(path string) bool {
path = filepath.Base(path)
torrentID := strings.TrimSuffix(path, ".zurginfo")
// if binOnceDone returns true, it means the info file is deleted
// if false, then we check if it's one of the torrents we just fetched
// if not (both are false), then we delete the info file
if !t.binOnceDone(torrentID, false) && !freshIDs.ContainsOne(torrentID) {
if !freshIDs.ContainsOne(torrentID) {
t.deleteInfoFile(torrentID)
return false
}
t.deleteOnceDone(torrentID, false)
return false
})