do not overwrite info
This commit is contained in:
@@ -102,10 +102,28 @@ func (t *TorrentManager) repairAll() {
|
||||
|
||||
func (t *TorrentManager) Repair(torrent *Torrent) {
|
||||
// save the broken files to the file cache
|
||||
var brokenFileIDs []int
|
||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
if file.Link == "repair" {
|
||||
brokenFileIDs = append(brokenFileIDs, file.ID)
|
||||
}
|
||||
})
|
||||
infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE)
|
||||
torrent.DownloadedIDs.Each(func(id string) bool {
|
||||
infoCache.Set(id, torrent)
|
||||
t.writeTorrentToFile(id, torrent, false)
|
||||
info, _ := infoCache.Get(id)
|
||||
info.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
found := false
|
||||
for _, brokenFileID := range brokenFileIDs {
|
||||
if file.ID == brokenFileID {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if found {
|
||||
file.Link = "unselect"
|
||||
}
|
||||
})
|
||||
t.writeTorrentToFile(id, info, false)
|
||||
return false
|
||||
})
|
||||
_ = t.workerPool.Submit(func() {
|
||||
@@ -205,7 +223,6 @@ func (t *TorrentManager) repair(torrent *Torrent) {
|
||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
if file.Link == "repair" || file.Link == "" {
|
||||
brokenFiles = append(brokenFiles, *file)
|
||||
file.Link = "repairing"
|
||||
}
|
||||
})
|
||||
t.log.Debugf("During repair, zurg found %d broken files for torrent %s", len(brokenFiles), t.GetKey(torrent))
|
||||
@@ -370,7 +387,7 @@ func (t *TorrentManager) markAsUnfixable(torrent *Torrent) {
|
||||
torrent.DownloadedIDs.Each(func(id string) bool {
|
||||
info, _ := infoCache.Get(id)
|
||||
info.Unfixable = true
|
||||
t.writeTorrentToFile(id, torrent, false)
|
||||
t.writeTorrentToFile(id, info, false)
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user