Fix duration bug in config
This commit is contained in:
@@ -75,7 +75,7 @@ func Start(ctx context.Context) error {
|
|||||||
|
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
if err := startServices(ctx, wd, srv); err != nil {
|
if err := startServices(ctx, cancelSvc, wd, srv); err != nil {
|
||||||
_log.Error().Err(err).Msg("Error starting services")
|
_log.Error().Err(err).Msg("Error starting services")
|
||||||
cancelSvc()
|
cancelSvc()
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ func Start(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func startServices(ctx context.Context, wd *webdav.WebDav, srv *server.Server) error {
|
func startServices(ctx context.Context, cancelSvc context.CancelFunc, wd *webdav.WebDav, srv *server.Server) error {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
|
|
||||||
@@ -177,7 +177,11 @@ func startServices(ctx context.Context, wd *webdav.WebDav, srv *server.Server) e
|
|||||||
for err := range errChan {
|
for err := range errChan {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_log.Error().Err(err).Msg("Service error detected")
|
_log.Error().Err(err).Msg("Service error detected")
|
||||||
// Don't shut down the whole app
|
// If the error is critical, return it to stop the main loop
|
||||||
|
if ctx.Err() == nil {
|
||||||
|
_log.Error().Msg("Stopping services due to error")
|
||||||
|
cancelSvc() // Cancel the service context to stop all services
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -91,7 +90,7 @@ type Config struct {
|
|||||||
UseAuth bool `json:"use_auth,omitempty"`
|
UseAuth bool `json:"use_auth,omitempty"`
|
||||||
Auth *Auth `json:"-"`
|
Auth *Auth `json:"-"`
|
||||||
DiscordWebhook string `json:"discord_webhook_url,omitempty"`
|
DiscordWebhook string `json:"discord_webhook_url,omitempty"`
|
||||||
RemoveStalledAfter time.Duration `json:"remove_stalled_after,omitempty"`
|
RemoveStalledAfter string `json:"remove_stalled_after,omitzero"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) JsonFile() string {
|
func (c *Config) JsonFile() string {
|
||||||
|
|||||||
@@ -258,6 +258,7 @@ func (c *Cache) reInsertTorrent(ct *CachedTorrent) (*CachedTorrent, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cache) resetInvalidLinks() {
|
func (c *Cache) resetInvalidLinks() {
|
||||||
|
c.logger.Debug().Msgf("Resetting accounts")
|
||||||
c.invalidDownloadLinks = sync.Map{}
|
c.invalidDownloadLinks = sync.Map{}
|
||||||
c.client.Accounts().Reset() // Reset the active download keys
|
c.client.Accounts().Reset() // Reset the active download keys
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -49,7 +49,12 @@ func Get() *Store {
|
|||||||
skipPreCache: qbitCfg.SkipPreCache,
|
skipPreCache: qbitCfg.SkipPreCache,
|
||||||
downloadSemaphore: make(chan struct{}, cmp.Or(qbitCfg.MaxDownloads, 5)),
|
downloadSemaphore: make(chan struct{}, cmp.Or(qbitCfg.MaxDownloads, 5)),
|
||||||
importsQueue: NewImportQueue(context.Background(), 1000),
|
importsQueue: NewImportQueue(context.Background(), 1000),
|
||||||
removeStalledAfter: cfg.RemoveStalledAfter,
|
}
|
||||||
|
if cfg.RemoveStalledAfter != "" {
|
||||||
|
removeStalledAfter, err := time.ParseDuration(cfg.RemoveStalledAfter)
|
||||||
|
if err == nil {
|
||||||
|
instance.removeStalledAfter = removeStalledAfter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return instance
|
return instance
|
||||||
|
|||||||
Reference in New Issue
Block a user