Remove annoying logs

This commit is contained in:
Ben Sarmiento
2024-01-28 18:27:39 +01:00
parent 00e4f8013c
commit 0678af2bc2
6 changed files with 57 additions and 28 deletions

View File

@@ -32,6 +32,7 @@ type TorrentManager struct {
latestState *LibraryState
requiredVersion string
workerPool *ants.Pool
refreshPool *ants.Pool
repairPool *ants.Pool
repairTrigger chan *Torrent
repairSet mapset.Set[*Torrent]
@@ -43,7 +44,7 @@ type TorrentManager struct {
// NewTorrentManager creates a new torrent manager
// it will fetch all torrents and their info in the background
// and store them in-memory and cached in files
func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, workerPool, repairPool *ants.Pool, log *logutil.Logger) *TorrentManager {
func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, workerPool, refreshPool, repairPool *ants.Pool, log *logutil.Logger) *TorrentManager {
t := &TorrentManager{
Config: cfg,
Api: api,
@@ -56,6 +57,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w
latestState: &LibraryState{},
requiredVersion: "0.9.3-hotfix.3",
workerPool: workerPool,
refreshPool: refreshPool,
repairPool: repairPool,
log: log,
}

View File

@@ -179,10 +179,13 @@ func (t *TorrentManager) repair(torrent *Torrent) {
t.log.Infof("repair_method#1: Torrent %s is still in progress but it should work once done (torrent is temporarily hidden until download has completed)", t.GetKey(torrent))
return
} else if info != nil && info.IsDone() && !t.isStillBroken(info, brokenFiles) {
ix := 0
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
file.Link = info.Links[ix]
ix++
torrent.SelectedFiles.IterCb(func(_ string, oldFile *File) {
for ix, newFile := range info.Files {
if oldFile.ID == newFile.ID {
oldFile.Link = info.Links[ix]
break
}
}
})
t.saveTorrentChangesToDisk(torrent, nil)
t.log.Infof("Successfully repaired torrent %s using repair_method#1", t.GetKey(torrent))
@@ -521,12 +524,10 @@ func (t *TorrentManager) handleFixers(fixer realdebrid.Torrent) *Torrent {
if info.IsDone() {
if !t.isStillBroken(info, brokenFiles) {
ix := 0
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
for _, brokenFile := range brokenFiles {
if file.ID == brokenFile.ID {
file.Link = info.Links[ix]
ix++
torrent.SelectedFiles.IterCb(func(_ string, oldFile *File) {
for ix, newFile := range info.Files {
if oldFile.ID == newFile.ID {
oldFile.Link = info.Links[ix]
break
}
}