initializing webdav server

This commit is contained in:
Mukhtar Akere
2025-03-18 10:02:10 +01:00
parent fa469c64c6
commit 5d2fabe20b
39 changed files with 1650 additions and 1141 deletions

View File

@@ -52,7 +52,7 @@ Loop:
func (q *QBit) ProcessManualFile(torrent *Torrent) (string, error) {
debridTorrent := torrent.DebridTorrent
q.logger.Info().Msgf("Downloading %d files...", len(debridTorrent.DownloadLinks))
q.logger.Info().Msgf("Downloading %d files...", len(debridTorrent.Files))
torrentPath := filepath.Join(q.DownloadFolder, debridTorrent.Arr.Name, utils.RemoveExtension(debridTorrent.OriginalFilename))
torrentPath = utils.RemoveInvalidChars(torrentPath)
err := os.MkdirAll(torrentPath, os.ModePerm)
@@ -103,21 +103,21 @@ func (q *QBit) downloadFiles(torrent *Torrent, parent string) {
Transport: tr,
},
}
for _, link := range debridTorrent.DownloadLinks {
if link.DownloadLink == "" {
q.logger.Info().Msgf("No download link found for %s", link.Filename)
for _, file := range debridTorrent.Files {
if file.DownloadLink == "" {
q.logger.Info().Msgf("No download link found for %s", file.Name)
continue
}
wg.Add(1)
semaphore <- struct{}{}
go func(link debrid.DownloadLinks) {
go func(file debrid.File) {
defer wg.Done()
defer func() { <-semaphore }()
filename := link.Filename
filename := file.Link
err := Download(
client,
link.DownloadLink,
file.DownloadLink,
filepath.Join(parent, filename),
progressCallback,
)
@@ -127,7 +127,7 @@ func (q *QBit) downloadFiles(torrent *Torrent, parent string) {
} else {
q.logger.Info().Msgf("Downloaded %s", filename)
}
}(link)
}(file)
}
wg.Wait()
q.logger.Info().Msgf("Downloaded all files for %s", debridTorrent.Name)

View File

@@ -34,7 +34,7 @@ func New() *QBit {
DownloadFolder: cfg.DownloadFolder,
Categories: cfg.Categories,
Storage: NewTorrentStorage(filepath.Join(_cfg.Path, "torrents.json")),
logger: logger.NewLogger("qbit", _cfg.LogLevel, os.Stdout),
logger: logger.NewLogger("qbit", _cfg.LogLevel),
RefreshInterval: refreshInterval,
SkipPreCache: cfg.SkipPreCache,
}

View File

@@ -1,8 +1,8 @@
package qbit
import (
"encoding/json"
"fmt"
"github.com/goccy/go-json"
"os"
"sort"
"sync"

View File

@@ -185,7 +185,7 @@ func (q *QBit) UpdateTorrent(t *Torrent, debridTorrent *debrid.Torrent) *Torrent
}
_db := service.GetDebrid().GetByName(debridTorrent.Debrid)
if debridTorrent.Status != "downloaded" {
debridTorrent, _ = _db.GetTorrent(debridTorrent)
_ = _db.UpdateTorrent(debridTorrent)
}
t = q.UpdateTorrentMin(t, debridTorrent)
t.ContentPath = t.TorrentPath + string(os.PathSeparator)