Increment traffic monitors async
This commit is contained in:
@@ -20,13 +20,14 @@ import (
|
||||
)
|
||||
|
||||
type Handlers struct {
|
||||
downloader *universal.Downloader
|
||||
torMgr *torrent.TorrentManager
|
||||
cfg config.ConfigInterface
|
||||
api *realdebrid.RealDebrid
|
||||
workerPool *ants.Pool
|
||||
hosts []string
|
||||
log *logutil.Logger
|
||||
downloader *universal.Downloader
|
||||
torMgr *torrent.TorrentManager
|
||||
cfg config.ConfigInterface
|
||||
api *realdebrid.RealDebrid
|
||||
workerPool *ants.Pool
|
||||
hosts []string
|
||||
initialTraffic int64
|
||||
log *logutil.Logger
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -46,6 +47,16 @@ func AttachHandlers(router *chi.Mux, downloader *universal.Downloader, torMgr *t
|
||||
log: log,
|
||||
}
|
||||
|
||||
trafficDetails, err := api.GetTrafficDetails()
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get traffic details: %v", err)
|
||||
trafficDetails = make(map[string]int64)
|
||||
}
|
||||
hs.initialTraffic = 0
|
||||
if _, ok := trafficDetails["real-debrid.com"]; ok {
|
||||
hs.initialTraffic = trafficDetails["real-debrid.com"]
|
||||
}
|
||||
|
||||
if cfg.GetUsername() != "" {
|
||||
router.Use(hs.basicAuth)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user