Fix repair done check

This commit is contained in:
Ben Sarmiento
2024-01-20 16:38:09 +01:00
parent bf70aad909
commit 9a7d96b21f

View File

@@ -426,10 +426,30 @@ func getBrokenFiles(torrent *Torrent) []*File {
}
func (t *TorrentManager) isStillBroken(info *realdebrid.TorrentInfo, brokenFiles []*File) bool {
var selectedFiles []*File
// if some Links are empty, we need to repair it
for _, file := range info.Files {
if file.Selected == 0 {
continue
}
selectedFiles = append(selectedFiles, &File{
File: file,
Ended: info.Ended,
Link: "", // no link yet
})
}
if len(selectedFiles) == len(info.Links) {
// all links are still intact! good!
for i, file := range selectedFiles {
file.Link = info.Links[i]
}
} else {
return true
}
for _, oldFile := range brokenFiles {
for idx, newFile := range info.Files {
for idx, newFile := range selectedFiles {
if oldFile.Path == newFile.Path || oldFile.Bytes == newFile.Bytes {
unrestrict := t.UnrestrictUntilOk(info.Links[idx])
unrestrict := t.UnrestrictUntilOk(selectedFiles[idx].Link)
if unrestrict == nil || oldFile.Bytes != unrestrict.Filesize {
return true
}