Final bug fixes

This commit is contained in:
Mukhtar Akere
2025-08-09 19:57:32 +01:00
parent 3aeb806033
commit 0dd1efb07c
10 changed files with 21 additions and 42 deletions

11
main.go
View File

@@ -6,8 +6,6 @@ import (
"github.com/sirrobot01/decypharr/cmd/decypharr" "github.com/sirrobot01/decypharr/cmd/decypharr"
"github.com/sirrobot01/decypharr/internal/config" "github.com/sirrobot01/decypharr/internal/config"
"log" "log"
"net/http"
_ "net/http/pprof"
"os" "os"
"os/signal" "os/signal"
"runtime/debug" "runtime/debug"
@@ -27,15 +25,6 @@ func main() {
config.SetConfigPath(configPath) config.SetConfigPath(configPath)
config.Get() config.Get()
if os.Getenv("ENABLE_PPROF") == "true" {
go func() {
log.Println("Starting pprof server on :6060")
if err := http.ListenAndServe(":6060", nil); err != nil {
log.Printf("pprof server error: %v", err)
}
}()
}
// Create a context canceled on SIGINT/SIGTERM // Create a context canceled on SIGINT/SIGTERM
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop() defer stop()

View File

@@ -511,7 +511,7 @@ func (r *RealDebrid) CheckStatus(t *types.Torrent) (*types.Torrent, error) {
if status == "waiting_files_selection" { if status == "waiting_files_selection" {
t.Files = r.getTorrentFiles(t, data) t.Files = r.getTorrentFiles(t, data)
if len(t.Files) == 0 { if len(t.Files) == 0 {
return t, fmt.Errorf("no video files found") return t, fmt.Errorf("no valid files found")
} }
filesId := make([]string, 0) filesId := make([]string, 0)
for _, f := range t.Files { for _, f := range t.Files {

View File

@@ -3,7 +3,6 @@ package store
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/sirrobot01/decypharr/internal/utils" "github.com/sirrobot01/decypharr/internal/utils"
"github.com/sirrobot01/decypharr/pkg/debrid/types" "github.com/sirrobot01/decypharr/pkg/debrid/types"
) )
@@ -103,10 +102,8 @@ func (c *Cache) fetchDownloadLink(torrentName, filename, fileLink string) (*type
} }
c.logger.Trace().Msgf("Getting download link for %s(%s)", filename, file.Link) c.logger.Trace().Msgf("Getting download link for %s(%s)", filename, file.Link)
downloadLink, err := c.client.GetDownloadLink(ct.Torrent, &file) downloadLink, err := c.client.GetDownloadLink(ct.Torrent, &file)
if err != nil { if err != nil {
if errors.Is(err, utils.HosterUnavailableError) { if errors.Is(err, utils.HosterUnavailableError) {
c.logger.Trace(). c.logger.Trace().
Str("filename", filename). Str("filename", filename).
@@ -130,6 +127,7 @@ func (c *Cache) fetchDownloadLink(torrentName, filename, fileLink string) (*type
if downloadLink == nil { if downloadLink == nil {
return nil, fmt.Errorf("download link is empty after retry") return nil, fmt.Errorf("download link is empty after retry")
} }
return nil, nil
} else if errors.Is(err, utils.TrafficExceededError) { } else if errors.Is(err, utils.TrafficExceededError) {
// This is likely a fair usage limit error // This is likely a fair usage limit error
return nil, err return nil, err

View File

@@ -29,12 +29,6 @@ func (fi *fileInfo) IsDir() bool { return fi.isDir }
func (fi *fileInfo) ID() string { return fi.id } func (fi *fileInfo) ID() string { return fi.id }
func (fi *fileInfo) Sys() interface{} { return nil } func (fi *fileInfo) Sys() interface{} { return nil }
type RcloneRC struct {
URL string
User string
Pass string
}
func (c *Cache) RefreshListings(refreshRclone bool) { func (c *Cache) RefreshListings(refreshRclone bool) {
// Copy the torrents to a string|time map // Copy the torrents to a string|time map
c.torrents.refreshListing() // refresh torrent listings c.torrents.refreshListing() // refresh torrent listings

View File

@@ -153,7 +153,7 @@ func (s *Store) downloadFiles(torrent *Torrent, debridTorrent *types.Torrent, pa
func (s *Store) processSymlink(torrent *Torrent, debridTorrent *types.Torrent) (string, error) { func (s *Store) processSymlink(torrent *Torrent, debridTorrent *types.Torrent) (string, error) {
files := debridTorrent.Files files := debridTorrent.Files
if len(files) == 0 { if len(files) == 0 {
return "", fmt.Errorf("no video files found") return "", fmt.Errorf("no valid files found")
} }
s.logger.Info().Msgf("Checking symlinks for %d files...", len(files)) s.logger.Info().Msgf("Checking symlinks for %d files...", len(files))
rCloneBase := debridTorrent.MountPath rCloneBase := debridTorrent.MountPath

View File

@@ -96,7 +96,9 @@ func (s *Store) trackAvailableSlots(ctx context.Context) {
return return
} }
for _, slots := range availableSlots { for name, slots := range availableSlots {
s.logger.Debug().Msgf("Available slots for %s: %d", name, slots)
// If slots are available, process the next import request from the queue // If slots are available, process the next import request from the queue
for slots > 0 { for slots > 0 {
select { select {

View File

@@ -61,9 +61,8 @@ func (s *Store) processFiles(torrent *Torrent, debridTorrent *types.Torrent, imp
_arr := importReq.Arr _arr := importReq.Arr
backoff := time.NewTimer(s.refreshInterval) backoff := time.NewTimer(s.refreshInterval)
defer backoff.Stop() defer backoff.Stop()
for debridTorrent.Status != "downloaded" { for debridTorrent.Status != "downloaded" {
s.logger.Debug().Msgf("%s <- (%s) Download Progress: %.2f%%", debridTorrent.Debrid, debridTorrent.Name, debridTorrent.Progress)
dbT, err := client.CheckStatus(debridTorrent) dbT, err := client.CheckStatus(debridTorrent)
if err != nil { if err != nil {
s.logger.Error(). s.logger.Error().
@@ -90,16 +89,15 @@ func (s *Store) processFiles(torrent *Torrent, debridTorrent *types.Torrent, imp
torrent = s.partialTorrentUpdate(torrent, debridTorrent) torrent = s.partialTorrentUpdate(torrent, debridTorrent)
// Exit the loop for downloading statuses to prevent memory buildup // Exit the loop for downloading statuses to prevent memory buildup
exitCondition1 := debridTorrent.Status == "downloaded" if debridTorrent.Status == "downloaded" || !utils.Contains(downloadingStatuses, debridTorrent.Status) {
exitCondition2 := !utils.Contains(downloadingStatuses, debridTorrent.Status)
if exitCondition1 || exitCondition2 {
break break
} }
<-backoff.C select {
// Increase interval gradually, cap at max case <-backoff.C:
nextInterval := min(s.refreshInterval*2, 30*time.Second) // Increase interval gradually, cap at max
backoff.Reset(nextInterval) nextInterval := min(s.refreshInterval*2, 30*time.Second)
backoff.Reset(nextInterval)
}
} }
var torrentSymlinkPath string var torrentSymlinkPath string
var err error var err error
@@ -117,6 +115,7 @@ func (s *Store) processFiles(torrent *Torrent, debridTorrent *types.Torrent, imp
}() }()
s.logger.Error().Err(err).Msgf("Error occured while processing torrent %s", debridTorrent.Name) s.logger.Error().Err(err).Msgf("Error occured while processing torrent %s", debridTorrent.Name)
importReq.markAsFailed(err, torrent, debridTorrent) importReq.markAsFailed(err, torrent, debridTorrent)
return
} }
onSuccess := func(torrentSymlinkPath string) { onSuccess := func(torrentSymlinkPath string) {

File diff suppressed because one or more lines are too long

View File

@@ -166,13 +166,10 @@ class DownloadManager {
// Create a modal or detailed view for errors // Create a modal or detailed view for errors
const errorList = errors.map(error => `${error}`).join('\n'); const errorList = errors.map(error => `${error}`).join('\n');
console.error('Download errors:', errorList); console.error('Download errors:', errorList);
window.decypharrUtils.createToast(
// You could also show this in a modal for better UX `Errors occurred while adding torrents:\n${errorList}`,
setTimeout(() => { 'error'
if (confirm('Some torrents failed to add. Would you like to see the details?')) { );
alert(errorList);
}
}, 1000);
} }
clearForm() { clearForm() {

View File

@@ -157,7 +157,7 @@ func (wd *WebDav) mountHandlers(r chi.Router) {
r.Route("/"+h.Name, func(r chi.Router) { r.Route("/"+h.Name, func(r chi.Router) {
r.Use(h.readinessMiddleware) r.Use(h.readinessMiddleware)
r.Mount("/", h) r.Mount("/", h)
}) }) // Mount to /name since router is already prefixed with /webdav
} }
} }