Fix repair done check
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user