Fix possible issues
This commit is contained in:
@@ -106,11 +106,11 @@ func (t *TorrentManager) repairAll(torrent *Torrent) {
|
||||
}
|
||||
})
|
||||
if brokenFileIDs.Cardinality() > 0 {
|
||||
t.log.Debugf("Torrent %s has broken files (ids=%v), adding to repair list", t.GetKey(torrent), brokenFileIDs.ToSlice())
|
||||
t.log.Debugf("Torrent %s has %d broken files (ids=%v), adding to repair list", t.GetKey(torrent), brokenFileIDs.Cardinality(), brokenFileIDs.ToSlice())
|
||||
toRepair.Add(torrent)
|
||||
return
|
||||
}
|
||||
// check 2: for expired links
|
||||
// check 2: for unassigned links (this means the torrent has started to deteriorate)
|
||||
if torrent.UnassignedLinks.Cardinality() > 0 {
|
||||
t.log.Debugf("Torrent %s has unassigned links, adding to repair list", t.GetKey(torrent))
|
||||
toRepair.Add(torrent)
|
||||
@@ -170,7 +170,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
|
||||
// get all broken files
|
||||
brokenFiles := getBrokenFiles(torrent)
|
||||
t.log.Debugf("Torrent %s has %d broken out of %d files", t.GetKey(torrent), len(brokenFiles), torrent.SelectedFiles.Count())
|
||||
t.log.Debugf("Torrent %s has %d broken files (total is %d)", t.GetKey(torrent), len(brokenFiles), torrent.SelectedFiles.Count())
|
||||
brokenFileIDs := getFileIDs(brokenFiles)
|
||||
|
||||
// first step: redownload the whole torrent
|
||||
@@ -187,6 +187,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
for _, newFile := range selectedFiles {
|
||||
if oldFile.Bytes == newFile.Bytes {
|
||||
oldFile.Link = newFile.Link
|
||||
oldFile.IsBroken = false
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -220,9 +221,10 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
t.fixerAddCommand(redownloadedTorrent.ID, "repair")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
t.log.Infof("Torrent %s has no broken files to repair", t.GetKey(torrent))
|
||||
}
|
||||
|
||||
t.log.Infof("Torrent %s has no broken files to repair", t.GetKey(torrent))
|
||||
}
|
||||
|
||||
func (t *TorrentManager) assignUnassignedLinks(torrent *Torrent) bool {
|
||||
@@ -245,6 +247,7 @@ func (t *TorrentManager) assignUnassignedLinks(torrent *Torrent) bool {
|
||||
// base it on size because why not?
|
||||
if file.Bytes == unrestrict.Filesize {
|
||||
file.Link = link
|
||||
file.IsBroken = false
|
||||
assigned = true
|
||||
assignedCount++
|
||||
}
|
||||
@@ -275,10 +278,11 @@ func (t *TorrentManager) assignUnassignedLinks(torrent *Torrent) bool {
|
||||
ID: 0,
|
||||
Path: unassigned.Filename,
|
||||
Bytes: unassigned.Filesize,
|
||||
Selected: 1,
|
||||
Selected: 0,
|
||||
},
|
||||
Ended: torrent.Added,
|
||||
Link: unassigned.Link,
|
||||
Ended: torrent.Added,
|
||||
Link: unassigned.Link,
|
||||
IsBroken: false,
|
||||
}
|
||||
torrent.SelectedFiles.Set(unassigned.Filename, newFile)
|
||||
})
|
||||
@@ -470,15 +474,17 @@ func (t *TorrentManager) isStillBroken(info *realdebrid.TorrentInfo, brokenFiles
|
||||
continue
|
||||
}
|
||||
selectedFiles = append(selectedFiles, &File{
|
||||
File: file,
|
||||
Ended: info.Ended,
|
||||
Link: "", // no link yet
|
||||
File: file,
|
||||
Ended: info.Ended,
|
||||
Link: "", // no link yet
|
||||
IsBroken: true,
|
||||
})
|
||||
}
|
||||
if len(selectedFiles) == len(info.Links) {
|
||||
// all links are still intact! good!
|
||||
for i, file := range selectedFiles {
|
||||
file.Link = info.Links[i]
|
||||
file.IsBroken = false
|
||||
}
|
||||
} else {
|
||||
// if we can't assign links, it's still broken
|
||||
@@ -512,15 +518,17 @@ func getSelectedFiles(info *realdebrid.TorrentInfo) []*File {
|
||||
continue
|
||||
}
|
||||
selectedFiles = append(selectedFiles, &File{
|
||||
File: file,
|
||||
Ended: info.Ended,
|
||||
Link: "", // no link yet
|
||||
File: file,
|
||||
Ended: info.Ended,
|
||||
Link: "", // no link yet
|
||||
IsBroken: true,
|
||||
})
|
||||
}
|
||||
if len(selectedFiles) == len(info.Links) {
|
||||
// all links are still intact! good!
|
||||
for i, file := range selectedFiles {
|
||||
file.Link = info.Links[i]
|
||||
file.IsBroken = false
|
||||
}
|
||||
}
|
||||
return selectedFiles
|
||||
|
||||
Reference in New Issue
Block a user