saveTorrentChangesToDisk when relevant
This commit is contained in:
@@ -92,9 +92,7 @@ func (t *TorrentManager) repairAll(torrent *Torrent) {
|
||||
// save the broken files to the file cache
|
||||
// broken files are also added when trying to open a file
|
||||
if torrent.BrokenLinks.Cardinality() > 0 {
|
||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||
torrent.DownloadedIDs.Each(func(id string) bool {
|
||||
info, _ := infoCache.Get(id)
|
||||
t.saveTorrentChangesToDisk(torrent, func(info *Torrent) {
|
||||
hasBrokenFiles := false
|
||||
info.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
torrent.BrokenLinks.Each(func(brokenLink string) bool {
|
||||
@@ -108,9 +106,7 @@ func (t *TorrentManager) repairAll(torrent *Torrent) {
|
||||
})
|
||||
if hasBrokenFiles {
|
||||
info.BrokenLinks = torrent.BrokenLinks
|
||||
t.writeTorrentToFile(id, info)
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -183,6 +179,7 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
|
||||
// handle torrents with incomplete links for selected files
|
||||
if !t.assignUnassignedLinks(torrent) {
|
||||
t.log.Debugf("Ending repair process early for torrent %s", t.GetKey(torrent))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -206,6 +203,9 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
ix++
|
||||
})
|
||||
torrent.BrokenLinks = mapset.NewSet[string]()
|
||||
t.saveTorrentChangesToDisk(torrent, func(info *Torrent) {
|
||||
info.BrokenLinks = mapset.NewSet[string]()
|
||||
})
|
||||
t.log.Infof("Successfully repaired torrent %s using repair_method#1", t.GetKey(torrent))
|
||||
return
|
||||
}
|
||||
@@ -294,17 +294,12 @@ func (t *TorrentManager) assignUnassignedLinks(torrent *Torrent) bool {
|
||||
t.markAsUnfixable(torrent, "rar'ed by RD")
|
||||
t.markAsUnplayable(torrent, "rar'ed by RD")
|
||||
}
|
||||
t.log.Debugf("Ending repair process early for torrent %s", t.GetKey(torrent))
|
||||
return false
|
||||
}
|
||||
// empty the unassigned links as we have assigned them
|
||||
if torrent.UnassignedLinks.Cardinality() > 0 {
|
||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||
torrent.DownloadedIDs.Each(func(id string) bool {
|
||||
info, _ := infoCache.Get(id)
|
||||
t.saveTorrentChangesToDisk(torrent, func(info *Torrent) {
|
||||
info.UnassignedLinks = mapset.NewSet[string]()
|
||||
t.writeTorrentToFile(id, info)
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -469,12 +464,8 @@ func (t *TorrentManager) markAsUnplayable(torrent *Torrent, reason string) {
|
||||
func (t *TorrentManager) markAsUnfixable(torrent *Torrent, reason string) {
|
||||
t.log.Warnf("Marking torrent %s as unfixable - %s", t.GetKey(torrent), reason)
|
||||
torrent.UnrepairableReason = reason
|
||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||
torrent.DownloadedIDs.Each(func(id string) bool {
|
||||
info, _ := infoCache.Get(id)
|
||||
info.UnrepairableReason = reason
|
||||
t.writeTorrentToFile(id, info)
|
||||
return false
|
||||
t.saveTorrentChangesToDisk(torrent, func(t *Torrent) {
|
||||
t.UnrepairableReason = reason
|
||||
})
|
||||
}
|
||||
|
||||
@@ -562,6 +553,9 @@ func (t *TorrentManager) handleFixers(fixer realdebrid.Torrent) *Torrent {
|
||||
}
|
||||
})
|
||||
torrent.BrokenLinks = mapset.NewSet[string]()
|
||||
t.saveTorrentChangesToDisk(torrent, func(info *Torrent) {
|
||||
info.BrokenLinks = mapset.NewSet[string]()
|
||||
})
|
||||
t.log.Infof("Successfully repaired torrent %s using repair_method#2", t.GetKey(torrent))
|
||||
} else {
|
||||
t.log.Warnf("repair_method#2: Fixer is done but torrent %s is still broken; let's keep the fixer", t.GetKey(torrent))
|
||||
|
||||
Reference in New Issue
Block a user