Add repair worker

This commit is contained in:
Mukhtar Akere
2025-01-09 19:44:38 +01:00
parent 28e5342c66
commit 03c9657945
19 changed files with 783 additions and 235 deletions

View File

@@ -4,9 +4,12 @@ import (
"cmp"
"context"
"goBlack/common"
"goBlack/pkg/arr"
"goBlack/pkg/debrid"
"goBlack/pkg/proxy"
"goBlack/pkg/qbit"
"goBlack/pkg/repair"
"log"
"sync"
)
@@ -14,6 +17,7 @@ func Start(ctx context.Context, config *common.Config) error {
maxCacheSize := cmp.Or(config.MaxCacheSize, 1000)
deb := debrid.NewDebrid(config.Debrids, maxCacheSize)
arrs := arr.NewStorage(config.Arrs)
var wg sync.WaitGroup
errChan := make(chan error, 2)
@@ -31,12 +35,22 @@ func Start(ctx context.Context, config *common.Config) error {
wg.Add(1)
go func() {
defer wg.Done()
if err := qbit.Start(ctx, config, deb); err != nil {
if err := qbit.Start(ctx, config, deb, arrs); err != nil {
errChan <- err
}
}()
}
if config.Repair.Enabled {
wg.Add(1)
go func() {
defer wg.Done()
if err := repair.Start(ctx, config, arrs); err != nil {
log.Printf("Error during repair: %v", err)
}
}()
}
go func() {
wg.Wait()
close(errChan)