- Download Link fix
- reinsert fix
This commit is contained in:
Mukhtar Akere
2025-04-23 16:38:55 +01:00
parent 1a4db69b20
commit 267430e6fb
15 changed files with 358 additions and 236 deletions

View File

@@ -27,9 +27,9 @@ var sharedClient = &http.Client{
}
type File struct {
cache *debrid.Cache
fileId string
torrentId string
cache *debrid.Cache
fileId string
torrentName string
modTime time.Time
@@ -63,7 +63,7 @@ func (f *File) getDownloadLink() (string, error) {
if f.downloadLink != "" && isValidURL(f.downloadLink) {
return f.downloadLink, nil
}
downloadLink, err := f.cache.GetDownloadLink(f.torrentId, f.name, f.link)
downloadLink, err := f.cache.GetDownloadLink(f.torrentName, f.name, f.link)
if err != nil {
return "", err
}
@@ -84,6 +84,7 @@ func (f *File) stream() (*http.Response, error) {
downloadLink, err = f.getDownloadLink()
if err != nil {
_log.Trace().Msgf("Failed to get download link for %s. %s", f.name, err)
return nil, io.EOF
}

View File

@@ -2,7 +2,6 @@ package webdav
import (
"bytes"
"cmp"
"context"
"fmt"
"github.com/rs/zerolog"
@@ -171,7 +170,7 @@ func (h *Handler) OpenFile(ctx context.Context, name string, flag int, perm os.F
// Torrent folder level
return &File{
cache: h.cache,
torrentId: cachedTorrent.Id,
torrentName: torrentName,
isDir: true,
children: h.getFileInfos(cachedTorrent.Torrent),
name: cachedTorrent.Name,
@@ -186,7 +185,7 @@ func (h *Handler) OpenFile(ctx context.Context, name string, flag int, perm os.F
if file, ok := cachedTorrent.Files[filename]; ok {
return &File{
cache: h.cache,
torrentId: cmp.Or(file.TorrentId, cachedTorrent.Id),
torrentName: torrentName,
fileId: file.Id,
isDir: false,
name: file.Name,