From 1a7c6779018e0384aa4fdd0ff760a191c9e3f860 Mon Sep 17 00:00:00 2001 From: Roy Xiang Date: Mon, 4 Dec 2023 13:10:52 +0800 Subject: [PATCH] fix(putio): SimultaneousDownloadLimit is no longer available --- putio/main.go | 10 ++++------ putio/task.go | 6 +++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/putio/main.go b/putio/main.go index ee711a3..201e005 100644 --- a/putio/main.go +++ b/putio/main.go @@ -19,14 +19,12 @@ func New(token string, maxTransfers int) *Put { if err != nil || !info.AccountActive { log.Fatal("You must have an active Put.io subscription") } - if maxTransfers <= 0 || maxTransfers > info.SimultaneousDownloadLimit { - maxTransfers = info.SimultaneousDownloadLimit - } result := &Put{ - Client: client, - MaxTransfers: maxTransfers, - DefaultDownloadFolder: "", + Client: client, + } + if maxTransfers > 0 { + result.MaxTransfers = maxTransfers } if settings, err := client.Account.Settings(ctx); err == nil && settings.DefaultDownloadFolder != RootFolderId { fileInfo := result.GetFileInfo(settings.DefaultDownloadFolder) diff --git a/putio/task.go b/putio/task.go index 71a614e..39f8af7 100644 --- a/putio/task.go +++ b/putio/task.go @@ -46,6 +46,11 @@ func (put *Put) CleanupTransfers() { put.mu.Lock() defer put.mu.Unlock() + count := put.MaxTransfers - 1 + if count < 0 { + return + } + ctx := context.Background() transfers, err := put.Client.Transfers.List(ctx) if err != nil { @@ -53,7 +58,6 @@ func (put *Put) CleanupTransfers() { } sort.Sort(SortedTransfers(transfers)) - count := put.MaxTransfers - 1 var idsToBeCanceled []int64 var numToBeCanceled, numToBeCleaned int for _, transfer := range transfers {