From e4f86097e8e79ef1378971349721409b683adbe6 Mon Sep 17 00:00:00 2001 From: liwei Date: Fri, 10 Feb 2023 15:27:15 +0800 Subject: [PATCH] fix: bt resolve --- internal/protocol/bt/fetcher.go | 2 +- internal/protocol/bt/fetcher_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/protocol/bt/fetcher.go b/internal/protocol/bt/fetcher.go index 69d7aafc..0610236b 100644 --- a/internal/protocol/bt/fetcher.go +++ b/internal/protocol/bt/fetcher.go @@ -84,7 +84,7 @@ func (f *Fetcher) Resolve(req *base.Request) error { for i, file := range f.torrent.Files() { res.Files[i] = &base.FileInfo{ Name: filepath.Base(file.DisplayPath()), - Path: util.Dir(path.Join(f.torrent.Info().Name, file.Path())), + Path: util.Dir(file.Path()), Size: file.Length(), } res.Size += file.Length() diff --git a/internal/protocol/bt/fetcher_test.go b/internal/protocol/bt/fetcher_test.go index 84e34f9f..9c881e5f 100644 --- a/internal/protocol/bt/fetcher_test.go +++ b/internal/protocol/bt/fetcher_test.go @@ -27,13 +27,13 @@ func doResolve(t *testing.T, fetcher fetcher.Fetcher) { } want := &base.Resource{ - Name: "ubuntu-22.04-live-server-amd64.iso", - Size: 1466714112, - Range: true, + Name: "ubuntu-22.04-live-server-amd64.iso", + Size: 1466714112, + Range: true, + RootDir: "ubuntu-22.04-live-server-amd64.iso", Files: []*base.FileInfo{ { Name: "ubuntu-22.04-live-server-amd64.iso", - Path: "ubuntu-22.04-live-server-amd64.iso", Size: 1466714112, }, },