repair fixes!
This commit is contained in:
@@ -123,7 +123,8 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, p
|
||||
t.SetChecksum(t.getChecksum())
|
||||
|
||||
if t.cfg.EnableRepair() {
|
||||
go t.repairAll()
|
||||
t.log.Info("Checking for torrents to repair")
|
||||
t.repairAll()
|
||||
}
|
||||
go t.startRefreshJob()
|
||||
|
||||
@@ -317,7 +318,8 @@ func (t *TorrentManager) startRefreshJob() {
|
||||
t.SetChecksum(t.getChecksum())
|
||||
|
||||
if t.cfg.EnableRepair() {
|
||||
go t.repairAll()
|
||||
t.log.Info("Checking for torrents to repair")
|
||||
t.repairAll()
|
||||
}
|
||||
go OnLibraryUpdateHook(t.cfg)
|
||||
}
|
||||
@@ -371,11 +373,11 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
|
||||
var isChaotic bool
|
||||
selectedFiles, isChaotic = t.organizeChaos(info.Links, selectedFiles)
|
||||
if isChaotic {
|
||||
t.log.Warnf("Torrent id=%s %s is unplayable; it is always returning a rar file (it will no longer show up in your directories)", info.ID, info.Name)
|
||||
t.log.Warnf("Torrent id=%s %s is unplayable; it is always returning a rar file (it will no longer show up in your directories, zurg suggests you delete it)", info.ID, info.Name)
|
||||
// t.log.Debugf("You can try fixing it yourself magnet:?xt=urn:btih:%s", info.Hash)
|
||||
return nil
|
||||
} else if streamableCount == 1 {
|
||||
t.log.Warnf("Torrent id=%s %s is unplayable; the lone streamable link has expired (it will no longer show up in your directories)", info.ID, info.Name)
|
||||
t.log.Warnf("Torrent id=%s %s is unplayable; the lone streamable link has expired (it will no longer show up in your directories, zurg suggests you delete it)", info.ID, info.Name)
|
||||
// t.log.Debugf("You can try fixing it yourself magnet:?xt=urn:btih:%s", info.Hash)
|
||||
return nil
|
||||
}
|
||||
@@ -523,11 +525,15 @@ func (t *TorrentManager) organizeChaos(links []string, selectedFiles []*File) ([
|
||||
}
|
||||
|
||||
func (t *TorrentManager) repairAll() {
|
||||
t.log.Info("Checking for torrents to repair")
|
||||
proceed := t.canCapacityHandle() // blocks for approx 45 minutes if active torrents are full
|
||||
if !proceed {
|
||||
t.log.Error("Reached the max number of active torrents, cannot start repair")
|
||||
return
|
||||
}
|
||||
|
||||
allTorrents, _ := t.DirectoryMap.Get(ALL_TORRENTS)
|
||||
allTorrents.IterCb(func(_ string, torrent *Torrent) {
|
||||
if torrent.InProgress() {
|
||||
t.log.Infof("Torrent %s is in progress, cannot repair", torrent.AccessKey)
|
||||
return
|
||||
}
|
||||
forRepair := false
|
||||
@@ -537,7 +543,8 @@ func (t *TorrentManager) repairAll() {
|
||||
}
|
||||
})
|
||||
if forRepair {
|
||||
t.Repair(torrent.AccessKey)
|
||||
t.log.Infof("Repairing %s", torrent.AccessKey)
|
||||
go t.Repair(torrent.AccessKey)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -551,7 +558,7 @@ func (t *TorrentManager) Repair(accessKey string) {
|
||||
allTorrents, _ := t.DirectoryMap.Get(ALL_TORRENTS)
|
||||
torrent, _ := allTorrents.Get(accessKey)
|
||||
if torrent == nil {
|
||||
t.log.Warnf("Cannot find torrent %s anymore to repair it", accessKey)
|
||||
t.log.Warnf("Cannot find torrent %s anymore so we are not repairing it", accessKey)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -560,12 +567,6 @@ func (t *TorrentManager) Repair(accessKey string) {
|
||||
return
|
||||
}
|
||||
|
||||
proceed := t.canCapacityHandle() // blocks for approx 45 minutes
|
||||
if !proceed {
|
||||
t.log.Error("Cannot add more torrents, ignoring repair request")
|
||||
return
|
||||
}
|
||||
|
||||
// make the file messy
|
||||
t.log.Infof("Evaluating whole torrent to find the correct files for torrent: %s", torrent.AccessKey)
|
||||
|
||||
@@ -593,6 +594,12 @@ func (t *TorrentManager) Repair(accessKey string) {
|
||||
}
|
||||
}
|
||||
|
||||
proceed := t.canCapacityHandle() // blocks for approx 45 minutes if active torrents are full
|
||||
if !proceed {
|
||||
t.log.Error("Reached the max number of active torrents, cannot continue with the repair")
|
||||
return
|
||||
}
|
||||
|
||||
// first solution: add the same selection, maybe it can be fixed by reinsertion?
|
||||
if t.reinsertTorrent(torrent, "") {
|
||||
t.log.Infof("Successfully downloaded torrent %s to repair it", torrent.AccessKey)
|
||||
|
||||
Reference in New Issue
Block a user