use a new thread safe map

This commit is contained in:
Ben Sarmiento
2023-11-18 12:53:39 +01:00
parent b669f8d673
commit 0e9302f3b5
15 changed files with 577 additions and 535 deletions

View File

@@ -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"`