Proper logging and fixing for unavailable files

This commit is contained in:
Ben Sarmiento
2023-11-26 13:04:40 +01:00
parent c715a4a833
commit 5f65a3873b
5 changed files with 40 additions and 20 deletions

View File

@@ -538,7 +538,7 @@ func (t *TorrentManager) repairAll() {
allTorrents, _ := t.DirectoryMap.Get(ALL_TORRENTS)
allTorrents.IterCb(func(_ string, torrent *Torrent) {
if torrent.InProgress() {
if torrent.AnyInProgress() {
t.log.Debugf("Skipping %s for repairs because it is in progress", torrent.AccessKey)
return
}
@@ -588,7 +588,7 @@ func (t *TorrentManager) Repair(accessKey string) {
return
}
if torrent.InProgress() {
if torrent.AnyInProgress() {
t.log.Infof("Torrent %s is in progress, cannot repair", torrent.AccessKey)
return
}

View File

@@ -13,7 +13,7 @@ type Torrent struct {
Instances []realdebrid.TorrentInfo
}
func (t *Torrent) InProgress() bool {
func (t *Torrent) AnyInProgress() bool {
for _, instance := range t.Instances {
if instance.Progress < 100 {
return true
@@ -22,6 +22,16 @@ func (t *Torrent) InProgress() bool {
return false
}
func (t *Torrent) AllInProgress() bool {
count := 0
for _, instance := range t.Instances {
if instance.Progress < 100 {
count++
}
}
return count == len(t.Instances)
}
type File struct {
realdebrid.File
Added string