hotfix
This commit is contained in:
@@ -89,7 +89,7 @@ type Cache struct {
|
|||||||
invalidDownloadLinks *xsync.Map[string, string]
|
invalidDownloadLinks *xsync.Map[string, string]
|
||||||
repairRequest *xsync.Map[string, *reInsertRequest]
|
repairRequest *xsync.Map[string, *reInsertRequest]
|
||||||
failedToReinsert *xsync.Map[string, struct{}]
|
failedToReinsert *xsync.Map[string, struct{}]
|
||||||
failedLinksCounter *xsync.Map[string, *atomic.Int32] // link -> counter
|
failedLinksCounter *xsync.Map[string, atomic.Int32] // link -> counter
|
||||||
|
|
||||||
// repair
|
// repair
|
||||||
repairChan chan RepairRequest
|
repairChan chan RepairRequest
|
||||||
@@ -198,7 +198,7 @@ func NewDebridCache(dc config.Debrid, client common.Client, mounter *rclone.Moun
|
|||||||
invalidDownloadLinks: xsync.NewMap[string, string](),
|
invalidDownloadLinks: xsync.NewMap[string, string](),
|
||||||
repairRequest: xsync.NewMap[string, *reInsertRequest](),
|
repairRequest: xsync.NewMap[string, *reInsertRequest](),
|
||||||
failedToReinsert: xsync.NewMap[string, struct{}](),
|
failedToReinsert: xsync.NewMap[string, struct{}](),
|
||||||
failedLinksCounter: xsync.NewMap[string, *atomic.Int32](),
|
failedLinksCounter: xsync.NewMap[string, atomic.Int32](),
|
||||||
streamClient: httpClient,
|
streamClient: httpClient,
|
||||||
repairChan: make(chan RepairRequest, 100), // Initialize the repair channel, max 100 requests buffered
|
repairChan: make(chan RepairRequest, 100), // Initialize the repair channel, max 100 requests buffered
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,12 +146,16 @@ func (c *Cache) checkDownloadLink(link string) (types.DownloadLink, error) {
|
|||||||
return types.DownloadLink{}, fmt.Errorf("download link not found for %s", link)
|
return types.DownloadLink{}, fmt.Errorf("download link not found for %s", link)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Cache) IncrementFailedLinkCounter(link string) int32 {
|
||||||
|
counter, _ := c.failedLinksCounter.LoadOrCompute(link, func() (atomic.Int32, bool) {
|
||||||
|
return atomic.Int32{}, true
|
||||||
|
})
|
||||||
|
return counter.Add(1)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Cache) MarkLinkAsInvalid(downloadLink types.DownloadLink, reason string) {
|
func (c *Cache) MarkLinkAsInvalid(downloadLink types.DownloadLink, reason string) {
|
||||||
// Increment file link error counter
|
// Increment file link error counter
|
||||||
counter, _ := c.failedLinksCounter.LoadOrCompute(downloadLink.Link, func() (*atomic.Int32, bool) {
|
c.IncrementFailedLinkCounter(downloadLink.Link)
|
||||||
return &atomic.Int32{}, true
|
|
||||||
})
|
|
||||||
counter.Add(1)
|
|
||||||
|
|
||||||
c.invalidDownloadLinks.Store(downloadLink.DownloadLink, reason)
|
c.invalidDownloadLinks.Store(downloadLink.DownloadLink, reason)
|
||||||
// Remove the download api key from active
|
// Remove the download api key from active
|
||||||
|
|||||||
Reference in New Issue
Block a user