Final bug fixes
This commit is contained in:
11
main.go
11
main.go
@@ -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()
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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,17 +89,16 @@ 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 {
|
||||||
|
case <-backoff.C:
|
||||||
// Increase interval gradually, cap at max
|
// Increase interval gradually, cap at max
|
||||||
nextInterval := min(s.refreshInterval*2, 30*time.Second)
|
nextInterval := min(s.refreshInterval*2, 30*time.Second)
|
||||||
backoff.Reset(nextInterval)
|
backoff.Reset(nextInterval)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
var torrentSymlinkPath string
|
var torrentSymlinkPath string
|
||||||
var err error
|
var err error
|
||||||
debridTorrent.Arr = _arr
|
debridTorrent.Arr = _arr
|
||||||
@@ -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
@@ -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() {
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user