final prep for 1.0.3

This commit is contained in:
Mukhtar Akere
2025-06-03 10:45:23 +01:00
parent 30a1dd74a7
commit dfcf8708f1
13 changed files with 71 additions and 56 deletions
+3 -3
View File
@@ -190,7 +190,7 @@ func (ad *AllDebrid) GetTorrent(torrentId string) (*types.Torrent, error) {
var res TorrentInfoResponse
err = json.Unmarshal(resp, &res)
if err != nil {
ad.logger.Info().Msgf("Error unmarshalling torrent info: %s", err)
ad.logger.Error().Err(err).Msgf("Error unmarshalling torrent info")
return nil, err
}
data := res.Data.Magnets
@@ -232,7 +232,7 @@ func (ad *AllDebrid) UpdateTorrent(t *types.Torrent) error {
var res TorrentInfoResponse
err = json.Unmarshal(resp, &res)
if err != nil {
ad.logger.Info().Msgf("Error unmarshalling torrent info: %s", err)
ad.logger.Error().Err(err).Msgf("Error unmarshalling torrent info")
return err
}
data := res.Data.Magnets
@@ -393,7 +393,7 @@ func (ad *AllDebrid) GetTorrents() ([]*types.Torrent, error) {
var res TorrentsListResponse
err = json.Unmarshal(resp, &res)
if err != nil {
ad.logger.Info().Msgf("Error unmarshalling torrent info: %s", err)
ad.logger.Error().Err(err).Msgf("Error unmarshalling torrent info")
return torrents, err
}
for _, magnet := range res.Data.Magnets {
@@ -110,13 +110,13 @@ func (dl *DebridLink) IsAvailable(hashes []string) map[string]bool {
req, _ := http.NewRequest(http.MethodGet, url, nil)
resp, err := dl.client.MakeRequest(req)
if err != nil {
dl.logger.Info().Msgf("Error checking availability: %v", err)
dl.logger.Error().Err(err).Msgf("Error checking availability")
return result
}
var data AvailableResponse
err = json.Unmarshal(resp, &data)
if err != nil {
dl.logger.Info().Msgf("Error marshalling availability: %v", err)
dl.logger.Error().Err(err).Msgf("Error marshalling availability")
return result
}
if data.Value == nil {
@@ -406,7 +406,7 @@ func (dl *DebridLink) getTorrents(page, perPage int) ([]*types.Torrent, error) {
var res torrentInfo
err = json.Unmarshal(resp, &res)
if err != nil {
dl.logger.Info().Msgf("Error unmarshalling torrent info: %s", err)
dl.logger.Error().Err(err).Msgf("Error unmarshalling torrent info")
return torrents, err
}
@@ -81,7 +81,7 @@ func New(dc config.Debrid) (*RealDebrid, error) {
request.WithHeaders(headers),
request.WithRateLimiter(rl),
request.WithLogger(_log),
request.WithMaxRetries(5),
request.WithMaxRetries(10),
request.WithRetryableStatus(429, 502),
request.WithProxy(dc.Proxy),
),
@@ -302,13 +302,13 @@ func (r *RealDebrid) IsAvailable(hashes []string) map[string]bool {
req, _ := http.NewRequest(http.MethodGet, url, nil)
resp, err := r.client.MakeRequest(req)
if err != nil {
r.logger.Info().Msgf("Error checking availability: %v", err)
r.logger.Error().Err(err).Msgf("Error checking availability")
return result
}
var data AvailabilityResponse
err = json.Unmarshal(resp, &data)
if err != nil {
r.logger.Info().Msgf("Error marshalling availability: %v", err)
r.logger.Error().Err(err).Msgf("Error marshalling availability")
return result
}
for _, h := range hashes[i:end] {
+2 -2
View File
@@ -117,13 +117,13 @@ func (tb *Torbox) IsAvailable(hashes []string) map[string]bool {
req, _ := http.NewRequest(http.MethodGet, url, nil)
resp, err := tb.client.MakeRequest(req)
if err != nil {
tb.logger.Info().Msgf("Error checking availability: %v", err)
tb.logger.Error().Err(err).Msgf("Error checking availability")
return result
}
var res AvailableResponse
err = json.Unmarshal(resp, &res)
if err != nil {
tb.logger.Info().Msgf("Error marshalling availability: %v", err)
tb.logger.Error().Err(err).Msgf("Error marshalling availability")
return result
}
if res.Data == nil {
+2 -2
View File
@@ -231,6 +231,8 @@ func (c *Cache) Start(ctx context.Context) error {
if err := c.Sync(ctx); err != nil {
return fmt.Errorf("failed to sync cache: %w", err)
}
// Fire the ready channel
close(c.ready)
// initial download links
go c.refreshDownloadLinks(ctx)
@@ -242,8 +244,6 @@ func (c *Cache) Start(ctx context.Context) error {
c.repairChan = make(chan RepairRequest, 100)
go c.repairWorker(ctx)
// Fire the ready channel
close(c.ready)
cfg := config.Get()
name := c.client.GetName()
addr := cfg.BindAddress + ":" + cfg.Port + cfg.URLBase + "webdav/" + name + "/"
-3
View File
@@ -261,7 +261,4 @@ func (c *Cache) refreshDownloadLinks(ctx context.Context) {
c.downloadLinks.Delete(k)
}
}
c.logger.Trace().Msgf("Refreshed %d download links", len(downloadLinks))
}
+5 -5
View File
@@ -17,7 +17,7 @@ func (q *QBit) handleLogin(w http.ResponseWriter, r *http.Request) {
return
}
if err := _arr.Validate(); err != nil {
q.logger.Info().Msgf("Error validating arr: %v", err)
q.logger.Error().Err(err).Msgf("Error validating arr")
}
_, _ = w.Write([]byte("Ok."))
}
@@ -73,13 +73,13 @@ func (q *QBit) handleTorrentsAdd(w http.ResponseWriter, r *http.Request) {
contentType := r.Header.Get("Content-Type")
if strings.Contains(contentType, "multipart/form-data") {
if err := r.ParseMultipartForm(32 << 20); err != nil {
q.logger.Info().Msgf("Error parsing multipart form: %v", err)
q.logger.Error().Err(err).Msgf("Error parsing multipart form")
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
} else if strings.Contains(contentType, "application/x-www-form-urlencoded") {
if err := r.ParseForm(); err != nil {
q.logger.Info().Msgf("Error parsing form: %v", err)
q.logger.Error().Err(err).Msgf("Error parsing form")
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
@@ -105,7 +105,7 @@ func (q *QBit) handleTorrentsAdd(w http.ResponseWriter, r *http.Request) {
}
for _, url := range urlList {
if err := q.addMagnet(ctx, url, _arr, debridName, isSymlink); err != nil {
q.logger.Info().Msgf("Error adding magnet: %v", err)
q.logger.Error().Err(err).Msgf("Error adding magnet")
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
@@ -118,7 +118,7 @@ func (q *QBit) handleTorrentsAdd(w http.ResponseWriter, r *http.Request) {
if files := r.MultipartForm.File["torrents"]; len(files) > 0 {
for _, fileHeader := range files {
if err := q.addTorrent(ctx, fileHeader, _arr, debridName, isSymlink); err != nil {
q.logger.Info().Msgf("Error adding torrent: %v", err)
q.logger.Error().Err(err).Msgf("Error adding torrent")
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
+10 -11
View File
@@ -440,7 +440,7 @@ func (r *Repair) repairArr(job *Job, _arr string, tmdbId string) ([]arr.ContentF
}
// Check first media to confirm mounts are accessible
if !r.isMediaAccessible(media) {
r.logger.Info().Msgf("Skipping repair. Parent directory not accessible for. Check your mounts")
r.logger.Info().Msgf("Skipping repair. Parent directory not accessible. Check your mounts")
return brokenItems, nil
}
@@ -520,19 +520,18 @@ func (r *Repair) isMediaAccessible(media []arr.Content) bool {
firstFile := files[0]
symlinkPath := getSymlinkTarget(firstFile.Path)
if symlinkPath == "" {
r.logger.Debug().Msgf("No symlink target found for %s", firstFile.Path)
return false
}
r.logger.Debug().Msgf("Checking symlink parent directory for %s", symlinkPath)
parentSymlink := ""
if symlinkPath != "" {
parentSymlink = filepath.Dir(filepath.Dir(symlinkPath)) // /mnt/zurg/torrents/movie/movie.mkv -> /mnt/zurg/torrents
parentSymlink := filepath.Dir(filepath.Dir(symlinkPath)) // /mnt/zurg/torrents/movie/movie.mkv -> /mnt/zurg/torrents
if _, err := os.Stat(parentSymlink); os.IsNotExist(err) {
r.logger.Debug().Msgf("Cannot access parent directory %s for %s", parentSymlink, firstFile.Path)
return false
}
if parentSymlink != "" {
if _, err := os.Stat(parentSymlink); os.IsNotExist(err) {
return false
}
return true
}
return false
return true
}
func (r *Repair) getBrokenFiles(job *Job, media arr.Content) []arr.ContentFile {
+1 -1
View File
@@ -70,7 +70,7 @@ func (s *Server) Start(ctx context.Context) error {
go func() {
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
s.logger.Info().Msgf("Error starting server: %v", err)
s.logger.Error().Err(err).Msgf("Error starting server")
}
}()
+1 -1
View File
@@ -41,7 +41,7 @@ func GetStore() *Store {
arr: arrs,
debrid: deb,
torrents: newTorrentStorage(cfg.TorrentsFile()),
logger: logger.New("store"),
logger: logger.Default(), // Use default logger [decypharr]
refreshInterval: time.Duration(cmp.Or(qbitCfg.RefreshInterval, 10)) * time.Minute,
skipPreCache: qbitCfg.SkipPreCache,
downloadSemaphore: make(chan struct{}, cmp.Or(qbitCfg.MaxDownloads, 5)),
+1 -1
View File
@@ -101,7 +101,7 @@ func (s *Store) processFiles(torrent *Torrent, debridTorrent *types.Torrent, imp
go func() {
_ = client.DeleteTorrent(debridTorrent.Id)
}()
s.logger.Info().Msgf("Error: %v", err)
s.logger.Error().Err(err).Msgf("Error occured while processing torrent %s", debridTorrent.Name)
importReq.markAsFailed(err, torrent, debridTorrent)
return
}