Skip to content

Commit c9eeadf

Browse files
committed
set SeedIdleLimit as time Duration
to match the type of the torrent mutator
1 parent d0d6463 commit c9eeadf

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

torrent_accessors.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ type Torrent struct {
176176
RecheckProgress *float64 `json:"recheckProgress"`
177177
TimeDownloading *time.Duration `json:"-"` // from secondsDownloading
178178
TimeSeeding *time.Duration `json:"-"` // from secondsSeeding
179-
SeedIdleLimit *int64 `json:"seedIdleLimit"`
179+
SeedIdleLimit *time.Duration `json:"-"`
180180
SeedIdleMode *int64 `json:"seedIdleMode"`
181181
SeedRatioLimit *float64 `json:"seedRatioLimit"`
182182
SeedRatioMode *SeedRatioMode `json:"seedRatioMode"`
@@ -226,6 +226,7 @@ func (t *Torrent) UnmarshalJSON(data []byte) (err error) {
226226
PieceSize *int64 `json:"pieceSize"`
227227
SecondsDownloading *int64 `json:"secondsDownloading"`
228228
SecondsSeeding *int64 `json:"secondsSeeding"`
229+
SeedIdleLimit *int64 `json:"seedIdleLimit"`
229230
SizeWhenDone *int64 `json:"sizeWhenDone"`
230231
StartDate *int64 `json:"startDate"`
231232
TotalSize *int64 `json:"totalSize"`
@@ -271,6 +272,10 @@ func (t *Torrent) UnmarshalJSON(data []byte) (err error) {
271272
dur := time.Duration(*tmp.SecondsSeeding) * time.Second
272273
t.TimeSeeding = &dur
273274
}
275+
if tmp.SeedIdleLimit != nil {
276+
dur := time.Duration(*tmp.SeedIdleLimit) * time.Minute
277+
t.SeedIdleLimit = &dur
278+
}
274279
if tmp.SizeWhenDone != nil {
275280
swd := cunits.ImportInByte(float64(*tmp.SizeWhenDone))
276281
t.SizeWhenDone = &swd
@@ -308,6 +313,7 @@ func (t Torrent) MarshalJSON() (data []byte, err error) {
308313
DoneDate *int64 `json:"doneDate"`
309314
SecondsDownloading *int64 `json:"secondsDownloading"`
310315
SecondsSeeding *int64 `json:"secondsSeeding"`
316+
SeedIdleLimit *int64 `json:"seedIdleLimit"`
311317
StartDate *int64 `json:"startDate"`
312318
Wanted []int64 `json:"wanted"` // boolean in number form
313319
*RawTorrent
@@ -339,6 +345,10 @@ func (t Torrent) MarshalJSON() (data []byte, err error) {
339345
ss := int64(*t.TimeSeeding / time.Second)
340346
tmp.SecondsSeeding = &ss
341347
}
348+
if t.SeedIdleLimit != nil {
349+
sil := int64(*t.SeedIdleLimit / time.Minute)
350+
tmp.SeedIdleLimit = &sil
351+
}
342352
if t.StartDate != nil {
343353
st := t.StartDate.Unix()
344354
tmp.StartDate = &st

0 commit comments

Comments
 (0)