diff --git a/internal/service/qbittorrent_adp.go b/internal/service/qbittorrent_adp.go index 740e755..15aaf28 100644 --- a/internal/service/qbittorrent_adp.go +++ b/internal/service/qbittorrent_adp.go @@ -14,7 +14,6 @@ import ( "net/http" "net/http/cookiejar" "net/url" - "strconv" "strings" "sync" "time" @@ -299,40 +298,3 @@ func (a *QBitAdapter) ensureAuthLocked(ctx context.Context) error { } return a.loginLocked(ctx) } - -// --- 为了与现有的 QBitClient 兼容,添加转换辅助函数 --- - -// QBitTorrentToInfo 将旧的 QBitTorrent 转换为新的 TorrentInfo。 -func QBitTorrentToInfo(q QBitTorrent) TorrentInfo { - return TorrentInfo{ - Hash: q.Hash, - Name: q.Name, - Size: q.Size, - Progress: float64(q.Progress), - DLSpeed: q.DLSpeed, - UPSpeed: q.UpSpeed, - State: q.State, - SavePath: q.SavePath, - NumSeeds: q.NumSeeds, - NumLeechs: q.NumLeech, - } -} - -// TorrentInfoToQBit 将 TorrentInfo 转换回旧的 QBitTorrent 格式(兼容性)。 -func TorrentInfoToQBit(t TorrentInfo) QBitTorrent { - return QBitTorrent{ - Hash: t.Hash, - Name: t.Name, - State: t.State, - Progress: float32(t.Progress), - DLSpeed: t.DLSpeed, - UpSpeed: t.UPSpeed, - NumSeeds: t.NumSeeds, - NumLeech: t.NumLeechs, - Size: t.Size, - SavePath: t.SavePath, - } -} - -// unused import guard -var _ = strconv.Itoa diff --git a/internal/service/qbittorrent_convert.go b/internal/service/qbittorrent_convert.go new file mode 100644 index 0000000..b5c07ca --- /dev/null +++ b/internal/service/qbittorrent_convert.go @@ -0,0 +1,33 @@ +package service + +// QBitTorrentToInfo 将旧的 QBitTorrent 转换为新的 TorrentInfo。 +func QBitTorrentToInfo(q QBitTorrent) TorrentInfo { + return TorrentInfo{ + Hash: q.Hash, + Name: q.Name, + Size: q.Size, + Progress: float64(q.Progress), + DLSpeed: q.DLSpeed, + UPSpeed: q.UpSpeed, + State: q.State, + SavePath: q.SavePath, + NumSeeds: q.NumSeeds, + NumLeechs: q.NumLeech, + } +} + +// TorrentInfoToQBit 将 TorrentInfo 转换回旧的 QBitTorrent 格式(兼容性)。 +func TorrentInfoToQBit(t TorrentInfo) QBitTorrent { + return QBitTorrent{ + Hash: t.Hash, + Name: t.Name, + State: t.State, + Progress: float32(t.Progress), + DLSpeed: t.DLSpeed, + UpSpeed: t.UPSpeed, + NumSeeds: t.NumSeeds, + NumLeech: t.NumLeechs, + Size: t.Size, + SavePath: t.SavePath, + } +}