Delete if everything is unselected

This commit is contained in:
Ben Sarmiento
2023-11-21 14:16:53 +01:00
parent 0f336c15df
commit 48ad2bc3bf
6 changed files with 36 additions and 22 deletions

View File

@@ -535,16 +535,24 @@ func (t *TorrentManager) repairAll() {
return
}
forRepair := false
unselected := 0
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
if file.Link == "@" || file.ForRepair {
if file.Link == "repair" {
t.log.Debugf("Found a file to repair for torrent %s", torrent.AccessKey)
forRepair = true
}
if file.Link == "unselect" {
unselected++
}
})
if forRepair {
t.log.Infof("Repairing %s", torrent.AccessKey)
t.Repair(torrent.AccessKey)
}
if unselected == torrent.SelectedFiles.Count() && unselected > 0 {
t.log.Infof("Deleting %s", torrent.AccessKey)
t.Delete(torrent.AccessKey)
}
})
}
@@ -756,14 +764,17 @@ func (t *TorrentManager) canCapacityHandle() bool {
return true
}
if retryCount >= maxRetries {
t.log.Error("Max retries reached, exiting")
return false
}
delay := time.Duration(math.Pow(2, float64(retryCount))) * baseDelay
if delay > maxDelay {
delay = maxDelay
}
t.log.Infof("We have reached the max number of active torrents, waiting for %s seconds before retrying", delay)
if retryCount >= maxRetries {
t.log.Error("Max retries reached, exiting")
return false
}
time.Sleep(delay)
retryCount++
}

View File

@@ -24,8 +24,7 @@ func (t *Torrent) InProgress() bool {
type File struct {
realdebrid.File
Added string
Link string
ZurgFS uint64
ForRepair bool
Added string
Link string
ZurgFS uint64
}