use a new thread safe map
This commit is contained in:
@@ -29,6 +29,23 @@ type Torrent struct {
|
||||
Links []string `json:"links"`
|
||||
}
|
||||
|
||||
func (i *Torrent) UnmarshalJSON(data []byte) error {
|
||||
type Alias Torrent
|
||||
aux := &struct {
|
||||
Progress float64 `json:"progress"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(i),
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
i.Progress = int(math.Round(aux.Progress))
|
||||
return nil
|
||||
}
|
||||
|
||||
type TorrentInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"filename"`
|
||||
|
||||
Reference in New Issue
Block a user