Remove link on repair
This commit is contained in:
@@ -35,16 +35,40 @@ func (t *TorrentManager) repairAll() {
|
||||
return
|
||||
}
|
||||
|
||||
// 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)
|
||||
hasBrokenFiles := false
|
||||
info.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
torrent.BrokenLinks.Each(func(brokenLink string) bool {
|
||||
if file.Link == brokenLink {
|
||||
hasBrokenFiles = true
|
||||
file.Link = ""
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
})
|
||||
if hasBrokenFiles {
|
||||
info.BrokenLinks = torrent.BrokenLinks
|
||||
t.writeTorrentToFile(id, info)
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
// check 2: for broken files
|
||||
hasBrokenFiles := false
|
||||
brokenFileIDs := mapset.NewSet[int]()
|
||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
if !strings.HasPrefix(file.Link, "http") && file.Link != "unselect" {
|
||||
hasBrokenFiles = true
|
||||
return
|
||||
brokenFileIDs.Add(file.ID)
|
||||
}
|
||||
})
|
||||
if hasBrokenFiles {
|
||||
t.log.Debugf("Torrent %s has broken files, adding to repair list", t.GetKey(torrent))
|
||||
if brokenFileIDs.Cardinality() > 0 {
|
||||
t.log.Debugf("Torrent %s has broken files (ids=%v), adding to repair list", t.GetKey(torrent), brokenFileIDs.ToSlice())
|
||||
toRepair.Add(torrent)
|
||||
return
|
||||
}
|
||||
@@ -80,31 +104,6 @@ func (t *TorrentManager) Repair(torrent *Torrent) {
|
||||
|
||||
t.repairs.Add(t.GetKey(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)
|
||||
hasBrokenFiles := false
|
||||
info.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
torrent.BrokenLinks.Each(func(brokenLink string) bool {
|
||||
if file.Link == brokenLink {
|
||||
hasBrokenFiles = true
|
||||
file.Link = ""
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
})
|
||||
if hasBrokenFiles {
|
||||
info.BrokenLinks = torrent.BrokenLinks
|
||||
t.writeTorrentToFile(id, info)
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
t.log.Infof("Attempting repair for torrent %s", t.GetKey(torrent))
|
||||
|
||||
// blocks for approx 45 minutes if active torrents are full
|
||||
|
||||
@@ -55,7 +55,7 @@ func (dl *Downloader) DownloadFile(directory, torrentName, fileName string, resp
|
||||
if unrestrict == nil {
|
||||
log.Warnf("File %s cannot be unrestricted (link=%s)", fileName, link)
|
||||
torrent.BrokenLinks.Add(file.Link)
|
||||
file.Link = "repair"
|
||||
// file.Link = "repair"
|
||||
if cfg.EnableRepair() {
|
||||
torMgr.SetNewLatestState(intTor.LibraryState{})
|
||||
} else {
|
||||
@@ -167,7 +167,7 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
|
||||
log.Warnf("Cannot download file %s: %v", unrestrict.Download, err)
|
||||
if file != nil && unrestrict.Streamable == 1 {
|
||||
torrent.BrokenLinks.Add(file.Link)
|
||||
file.Link = "repair"
|
||||
// file.Link = "repair"
|
||||
if cfg.EnableRepair() && torrent != nil {
|
||||
torMgr.SetNewLatestState(intTor.LibraryState{})
|
||||
} else {
|
||||
@@ -184,7 +184,7 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
|
||||
if file != nil && unrestrict.Streamable == 1 {
|
||||
log.Warnf("Received a %s status code for file %s", download.Status, file.Path)
|
||||
torrent.BrokenLinks.Add(file.Link)
|
||||
file.Link = "repair"
|
||||
// file.Link = "repair"
|
||||
if cfg.EnableRepair() && torrent != nil {
|
||||
torMgr.SetNewLatestState(intTor.LibraryState{})
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user