- Fix alldebrid bug with webdav(for nested files)
- Add support for re-inserting broken files - Other minor bug fixes
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/puzpuzpuz/xsync/v3"
|
||||
"github.com/sirrobot01/decypharr/internal/config"
|
||||
"github.com/sirrobot01/decypharr/internal/request"
|
||||
"github.com/sirrobot01/decypharr/internal/utils"
|
||||
"github.com/sirrobot01/decypharr/pkg/debrid/types"
|
||||
@@ -53,6 +54,21 @@ func (c *Cache) IsTorrentBroken(t *CachedTorrent, filenames []string) bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
cfg := config.Get()
|
||||
// Try to reinsert the torrent if it's broken
|
||||
if cfg.Repair.ReInsert && isBroken && t.Torrent != nil {
|
||||
// Check if the torrent is already in progress
|
||||
if _, inProgress := c.repairsInProgress.Load(t.Torrent.Id); !inProgress {
|
||||
if err := c.reInsertTorrent(t); err != nil {
|
||||
c.logger.Error().Err(err).Str("torrentId", t.Torrent.Id).Msg("Failed to reinsert torrent")
|
||||
return true
|
||||
} else {
|
||||
c.logger.Debug().Str("torrentId", t.Torrent.Id).Msg("Reinserted torrent")
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isBroken
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ func (dl *DebridLink) UpdateTorrent(t *types.Torrent) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var res TorrentInfo
|
||||
var res torrentInfo
|
||||
err = json.Unmarshal(resp, &res)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -336,7 +336,7 @@ func (dl *DebridLink) getTorrents(page, perPage int) ([]*types.Torrent, error) {
|
||||
if err != nil {
|
||||
return torrents, err
|
||||
}
|
||||
var res TorrentInfo
|
||||
var res torrentInfo
|
||||
err = json.Unmarshal(resp, &res)
|
||||
if err != nil {
|
||||
dl.logger.Info().Msgf("Error unmarshalling torrent info: %s", err)
|
||||
|
||||
@@ -40,6 +40,6 @@ type debridLinkTorrentInfo struct {
|
||||
UploadSpeed int64 `json:"uploadSpeed"`
|
||||
}
|
||||
|
||||
type TorrentInfo APIResponse[[]debridLinkTorrentInfo]
|
||||
type torrentInfo APIResponse[[]debridLinkTorrentInfo]
|
||||
|
||||
type SubmitTorrentInfo APIResponse[debridLinkTorrentInfo]
|
||||
|
||||
@@ -105,7 +105,7 @@ func (r *RealDebrid) GetLogger() zerolog.Logger {
|
||||
return r.logger
|
||||
}
|
||||
|
||||
func getSelectedFiles(t *types.Torrent, data TorrentInfo) map[string]types.File {
|
||||
func getSelectedFiles(t *types.Torrent, data torrentInfo) map[string]types.File {
|
||||
selectedFiles := make([]types.File, 0)
|
||||
for _, f := range data.Files {
|
||||
if f.Selected == 1 {
|
||||
@@ -133,7 +133,7 @@ func getSelectedFiles(t *types.Torrent, data TorrentInfo) map[string]types.File
|
||||
// getTorrentFiles returns a list of torrent files from the torrent info
|
||||
// validate is used to determine if the files should be validated
|
||||
// if validate is false, selected files will be returned
|
||||
func getTorrentFiles(t *types.Torrent, data TorrentInfo) map[string]types.File {
|
||||
func getTorrentFiles(t *types.Torrent, data torrentInfo) map[string]types.File {
|
||||
files := make(map[string]types.File)
|
||||
cfg := config.Get()
|
||||
idx := 0
|
||||
@@ -268,7 +268,7 @@ func (r *RealDebrid) UpdateTorrent(t *types.Torrent) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var data TorrentInfo
|
||||
var data torrentInfo
|
||||
err = json.Unmarshal(resp, &data)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -299,7 +299,7 @@ func (r *RealDebrid) CheckStatus(t *types.Torrent, isSymlink bool) (*types.Torre
|
||||
r.logger.Info().Msgf("ERROR Checking file: %v", err)
|
||||
return t, err
|
||||
}
|
||||
var data TorrentInfo
|
||||
var data torrentInfo
|
||||
if err = json.Unmarshal(resp, &data); err != nil {
|
||||
return t, err
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ type AddMagnetSchema struct {
|
||||
Uri string `json:"uri"`
|
||||
}
|
||||
|
||||
type TorrentInfo struct {
|
||||
type torrentInfo struct {
|
||||
ID string `json:"id"`
|
||||
Filename string `json:"filename"`
|
||||
OriginalFilename string `json:"original_filename"`
|
||||
|
||||
Reference in New Issue
Block a user