Skip to content

Commit

Permalink
fix(putio): SimultaneousDownloadLimit is no longer available
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyXiang committed Dec 4, 2023
1 parent 7d32894 commit 1a7c677
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 4 additions & 6 deletions putio/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion putio/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ 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 {
return
}
sort.Sort(SortedTransfers(transfers))

count := put.MaxTransfers - 1
var idsToBeCanceled []int64
var numToBeCanceled, numToBeCleaned int
for _, transfer := range transfers {
Expand Down

0 comments on commit 1a7c677

Please sign in to comment.