Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(methods): implement MainData Update #42

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ type AppPreferences struct {
}

type MainData struct {
Rid int `json:"rid"`
Rid int64 `json:"rid"`
FullUpdate bool `json:"full_update"`
Torrents map[string]Torrent `json:"torrents"`
TorrentsRemoved []string `json:"torrents_removed"`
Expand All @@ -603,26 +603,26 @@ type MainData struct {
type ServerState struct {
AlltimeDl int64 `json:"alltime_dl"`
AlltimeUl int64 `json:"alltime_ul"`
AverageTimeQueue int `json:"average_time_queue"`
AverageTimeQueue int64 `json:"average_time_queue"`
ConnectionStatus string `json:"connection_status"`
DhtNodes int `json:"dht_nodes"`
DhtNodes int64 `json:"dht_nodes"`
DlInfoData int64 `json:"dl_info_data"`
DlInfoSpeed int `json:"dl_info_speed"`
DlRateLimit int `json:"dl_rate_limit"`
DlInfoSpeed int64 `json:"dl_info_speed"`
DlRateLimit int64 `json:"dl_rate_limit"`
FreeSpaceOnDisk uint64 `json:"free_space_on_disk"`
GlobalRatio string `json:"global_ratio"`
QueuedIoJobs int `json:"queued_io_jobs"`
QueuedIoJobs int64 `json:"queued_io_jobs"`
Queueing bool `json:"queueing"`
ReadCacheHits string `json:"read_cache_hits"`
ReadCacheOverload string `json:"read_cache_overload"`
RefreshInterval int `json:"refresh_interval"`
TotalBuffersSize int `json:"total_buffers_size"`
TotalPeerConnections int `json:"total_peer_connections"`
TotalQueuedSize int `json:"total_queued_size"`
RefreshInterval int64 `json:"refresh_interval"`
TotalBuffersSize int64 `json:"total_buffers_size"`
TotalPeerConnections int64 `json:"total_peer_connections"`
TotalQueuedSize int64 `json:"total_queued_size"`
TotalWastedSession int64 `json:"total_wasted_session"`
UpInfoData int64 `json:"up_info_data"`
UpInfoSpeed int `json:"up_info_speed"`
UpRateLimit int `json:"up_rate_limit"`
UpInfoSpeed int64 `json:"up_info_speed"`
UpRateLimit int64 `json:"up_rate_limit"`
UseAltSpeedLimits bool `json:"use_alt_speed_limits"`
WriteCacheOverload string `json:"write_cache_overload"`
}
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
module github.com/autobrr/go-qbittorrent

go 1.19
go 1.22.0

toolchain go1.23.2

require (
github.com/Masterminds/semver v1.5.0
github.com/avast/retry-go v3.0.0+incompatible
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f
golang.org/x/net v0.30.0
)

Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
5 changes: 1 addition & 4 deletions maindata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package qbittorrent

import (
"context"
"fmt"

"golang.org/x/exp/slices"
)
Expand All @@ -13,8 +12,6 @@ func (dest *MainData) Update(ctx context.Context, c *Client) error {
return err
}

fmt.Printf("Update: %#v\n", source)

if source.FullUpdate {
*dest = *source
return nil
Expand All @@ -28,7 +25,7 @@ func (dest *MainData) Update(ctx context.Context, c *Client) error {
remove(source.CategoriesRemoved, &dest.Categories)
remove(source.TorrentsRemoved, &dest.Torrents)
mergeSlice(source.Tags, &dest.Tags)
removeSlice(source.Tags, &dest.TagsRemoved)
removeSlice(source.TagsRemoved, &dest.Tags)
return nil
}

Expand Down