Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Commit

Permalink
Merge pull request #10 from mrobinsn/add-size-to-status
Browse files Browse the repository at this point in the history
Add Size to GetStatus
  • Loading branch information
Michael Robinson authored May 5, 2019
2 parents 12696af + 7dbd6cd commit 9500743
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rtorrent/rtorrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Status struct {
DownRate int
UpRate int
Ratio float64
Size int
}

// File represents a file in rTorrent
Expand Down Expand Up @@ -286,5 +287,11 @@ func (r *RTorrent) GetStatus(t Torrent) (Status, error) {
return s, errors.Wrap(err, "d.ratio XMLRPC call failed")
}
s.Ratio = float64(results.([]interface{})[0].(int)) / float64(1000)
// Size
results, err = r.xmlrpcClient.Call("d.size_bytes", t.Hash)
if err != nil {
return s, errors.Wrap(err, "d.size_bytes XMLRPC call failed")
}
s.Size = results.([]interface{})[0].(int)
return s, nil
}
1 change: 1 addition & 0 deletions rtorrent/rtorrent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func TestRTorrent(t *testing.T) {
require.False(t, status.Completed)
require.NotZero(t, status.CompletedBytes)
require.NotZero(t, status.DownRate)
require.NotZero(t, status.Size)
// require.NotZero(t, status.UpRate)
//require.NotZero(t, status.Ratio)
})
Expand Down

0 comments on commit 9500743

Please sign in to comment.