hotfixes
This commit is contained in:
@@ -194,7 +194,6 @@ func (ad *AllDebrid) CheckStatus(torrent *torrent.Torrent, isSymlink bool) (*tor
|
|||||||
break
|
break
|
||||||
} else if status == "downloading" {
|
} else if status == "downloading" {
|
||||||
if !ad.DownloadUncached {
|
if !ad.DownloadUncached {
|
||||||
go ad.DeleteTorrent(torrent)
|
|
||||||
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
||||||
}
|
}
|
||||||
// Break out of the loop if the torrent is downloading.
|
// Break out of the loop if the torrent is downloading.
|
||||||
|
|||||||
@@ -218,7 +218,6 @@ func (dl *DebridLink) CheckStatus(torrent *torrent.Torrent, isSymlink bool) (*to
|
|||||||
break
|
break
|
||||||
} else if status == "downloading" {
|
} else if status == "downloading" {
|
||||||
if !dl.DownloadUncached {
|
if !dl.DownloadUncached {
|
||||||
go dl.DeleteTorrent(torrent)
|
|
||||||
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
||||||
}
|
}
|
||||||
// Break out of the loop if the torrent is downloading.
|
// Break out of the loop if the torrent is downloading.
|
||||||
|
|||||||
@@ -249,7 +249,6 @@ func (r *RealDebrid) CheckStatus(t *torrent.Torrent, isSymlink bool) (*torrent.T
|
|||||||
break
|
break
|
||||||
} else if slices.Contains(downloadingStatus, status) {
|
} else if slices.Contains(downloadingStatus, status) {
|
||||||
if !r.DownloadUncached {
|
if !r.DownloadUncached {
|
||||||
go r.DeleteTorrent(t)
|
|
||||||
return t, fmt.Errorf("torrent: %s not cached", t.Name)
|
return t, fmt.Errorf("torrent: %s not cached", t.Name)
|
||||||
}
|
}
|
||||||
// Break out of the loop if the torrent is downloading.
|
// Break out of the loop if the torrent is downloading.
|
||||||
|
|||||||
@@ -234,7 +234,6 @@ func (tb *Torbox) CheckStatus(torrent *torrent.Torrent, isSymlink bool) (*torren
|
|||||||
break
|
break
|
||||||
} else if status == "downloading" {
|
} else if status == "downloading" {
|
||||||
if !tb.DownloadUncached {
|
if !tb.DownloadUncached {
|
||||||
go tb.DeleteTorrent(torrent)
|
|
||||||
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
return torrent, fmt.Errorf("torrent: %s not cached", torrent.Name)
|
||||||
}
|
}
|
||||||
// Break out of the loop if the torrent is downloading.
|
// Break out of the loop if the torrent is downloading.
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ func (i *ImportRequest) Process(q *QBit) (err error) {
|
|||||||
torrent := CreateTorrentFromMagnet(magnet, i.Arr.Name, "manual")
|
torrent := CreateTorrentFromMagnet(magnet, i.Arr.Name, "manual")
|
||||||
debridTorrent, err := debrid.ProcessTorrent(svc.Debrid, magnet, i.Arr, i.IsSymlink)
|
debridTorrent, err := debrid.ProcessTorrent(svc.Debrid, magnet, i.Arr, i.IsSymlink)
|
||||||
if err != nil || debridTorrent == nil {
|
if err != nil || debridTorrent == nil {
|
||||||
fmt.Println("Error deleting torrent: ", err)
|
|
||||||
if debridTorrent != nil {
|
if debridTorrent != nil {
|
||||||
dbClient := service.GetDebrid().GetByName(debridTorrent.Debrid)
|
dbClient := service.GetDebrid().GetByName(debridTorrent.Debrid)
|
||||||
go dbClient.DeleteTorrent(debridTorrent)
|
go dbClient.DeleteTorrent(debridTorrent)
|
||||||
|
|||||||
@@ -436,7 +436,7 @@ func (ui *Handler) handleGetConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
arrCfgs := make([]config.Arr, 0)
|
arrCfgs := make([]config.Arr, 0)
|
||||||
svc := service.GetService()
|
svc := service.GetService()
|
||||||
for _, a := range svc.Arr.GetAll() {
|
for _, a := range svc.Arr.GetAll() {
|
||||||
arrCfgs = append(arrCfgs, config.Arr{Host: a.Host, Name: a.Name, Token: a.Token})
|
arrCfgs = append(arrCfgs, config.Arr{Host: a.Host, Name: a.Name, Token: a.Token, Cleanup: a.Cleanup})
|
||||||
}
|
}
|
||||||
cfg.Arrs = arrCfgs
|
cfg.Arrs = arrCfgs
|
||||||
request.JSONResponse(w, cfg, http.StatusOK)
|
request.JSONResponse(w, cfg, http.StatusOK)
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/sirrobot01/debrid-blackhole/internal/config"
|
"github.com/sirrobot01/debrid-blackhole/internal/config"
|
||||||
"github.com/sirrobot01/debrid-blackhole/internal/logger"
|
"github.com/sirrobot01/debrid-blackhole/internal/logger"
|
||||||
"github.com/sirrobot01/debrid-blackhole/pkg/arr"
|
|
||||||
"github.com/sirrobot01/debrid-blackhole/pkg/service"
|
"github.com/sirrobot01/debrid-blackhole/pkg/service"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -68,17 +67,6 @@ func arrRefreshWorker(ctx context.Context, cfg *config.Config) {
|
|||||||
func cleanUpQueuesWorker(ctx context.Context, cfg *config.Config) {
|
func cleanUpQueuesWorker(ctx context.Context, cfg *config.Config) {
|
||||||
// Start Clean up Queues Worker
|
// Start Clean up Queues Worker
|
||||||
_logger := getLogger()
|
_logger := getLogger()
|
||||||
_arrs := service.GetService().Arr
|
|
||||||
filtered := make([]*arr.Arr, 0)
|
|
||||||
for _, a := range _arrs.GetAll() {
|
|
||||||
if a.Cleanup {
|
|
||||||
filtered = append(filtered, a)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(filtered) == 0 {
|
|
||||||
_logger.Debug().Msg("No ARR instances configured for cleanup")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_logger.Debug().Msg("Clean up Queues Worker started")
|
_logger.Debug().Msg("Clean up Queues Worker started")
|
||||||
cleanupCtx := context.WithValue(ctx, "worker", "cleanup")
|
cleanupCtx := context.WithValue(ctx, "worker", "cleanup")
|
||||||
cleanupTicker := time.NewTicker(time.Duration(10) * time.Second)
|
cleanupTicker := time.NewTicker(time.Duration(10) * time.Second)
|
||||||
@@ -94,7 +82,7 @@ func cleanUpQueuesWorker(ctx context.Context, cfg *config.Config) {
|
|||||||
if cleanupMutex.TryLock() {
|
if cleanupMutex.TryLock() {
|
||||||
go func() {
|
go func() {
|
||||||
defer cleanupMutex.Unlock()
|
defer cleanupMutex.Unlock()
|
||||||
cleanUpQueues(filtered)
|
cleanUpQueues()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,21 +90,23 @@ func cleanUpQueuesWorker(ctx context.Context, cfg *config.Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func refreshArrs() {
|
func refreshArrs() {
|
||||||
arrs := service.GetService().Arr
|
for _, a := range service.GetService().Arr.GetAll() {
|
||||||
for _, a := range arrs.GetAll() {
|
|
||||||
err := a.Refresh()
|
err := a.Refresh()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_logger := getLogger()
|
_logger := getLogger()
|
||||||
_logger.Debug().Err(err).Msgf("Error refreshing %s", a.Name)
|
_logger.Debug().Err(err).Msg("Error refreshing arr")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func cleanUpQueues(arrs []*arr.Arr) {
|
func cleanUpQueues() {
|
||||||
// Clean up queues
|
// Clean up queues
|
||||||
_logger := getLogger()
|
_logger := getLogger()
|
||||||
for _, a := range arrs {
|
for _, a := range service.GetService().Arr.GetAll() {
|
||||||
|
if !a.Cleanup {
|
||||||
|
continue
|
||||||
|
}
|
||||||
_logger.Debug().Msgf("Cleaning up queue for %s", a.Name)
|
_logger.Debug().Msgf("Cleaning up queue for %s", a.Name)
|
||||||
if err := a.CleanupQueue(); err != nil {
|
if err := a.CleanupQueue(); err != nil {
|
||||||
_logger.Debug().Err(err).Msg("Error cleaning up queue")
|
_logger.Debug().Err(err).Msg("Error cleaning up queue")
|
||||||
|
|||||||
Reference in New Issue
Block a user