Small refactors

This commit is contained in:
Ben Adrian Sarmiento
2024-07-09 22:44:09 +02:00
parent b56ad95835
commit 6fc09e8486
3 changed files with 5 additions and 18 deletions

View File

@@ -375,7 +375,7 @@ func (t *TorrentManager) assignDirectory(tor *Torrent, triggerHook bool, outputL
if outputLogs {
t.log.Warnf("No playable files for %s, moving to unplayable directory", accessKey)
}
t.markAsUnplayable(tor, "no playable files")
t.markAsUnplayable(tor)
return
}

View File

@@ -46,19 +46,6 @@ func (t *TorrentManager) StartRepairJob() {
}
}
})
// repair worker
t.workerPool.Submit(func() {
for {
select {
case torrent := <-t.repairChan:
t.invokeRepair(torrent)
case <-t.RepairWorkerKillSwitch:
t.repairLog.Info("Stopping periodic repair job")
return
}
}
})
}
// EnqueueForRepair allows an on-demand repair to be initiated.
@@ -447,7 +434,7 @@ func (t *TorrentManager) assignLinks(torrent *Torrent) bool {
} else {
t.repairLog.Warnf("Torrent %s is rar'ed and we cannot repair it, moving to unplayable directory", t.GetKey(torrent))
t.markAsUnfixable(torrent, "rar'ed by RD")
t.markAsUnplayable(torrent, "rar'ed by RD")
t.markAsUnplayable(torrent)
torrent.State.Event(context.Background(), "mark_as_repaired")
}
@@ -603,7 +590,7 @@ func (t *TorrentManager) canCapacityHandle() bool {
}
}
func (t *TorrentManager) markAsUnplayable(torrent *Torrent, reason string) {
func (t *TorrentManager) markAsUnplayable(torrent *Torrent) {
// reassign to unplayable torrents directory
t.DirectoryMap.IterCb(func(directory string, torrents cmap.ConcurrentMap[string, *Torrent]) {
if strings.HasPrefix(directory, "int__") {

View File

@@ -258,13 +258,13 @@ func (dl *Downloader) streamFileToResponse(
return
}
dl.workerPool.Submit(func() {
go func() {
dl.TrafficServed.Add(uint64(n))
if cfg.ShouldLogRequests() && bToMb(uint64(n)) > 0 {
log.Debugf("Served %d MB of file %s (range=%s)", bToMb(uint64(n)), unrestrict.Filename, req.Header.Get("Range"))
}
})
}()
}
func redirect(resp http.ResponseWriter, req *http.Request, url string) {