From d730c04c265ea6dd828f769a3a9af0456e8d8d9f Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Thu, 19 Nov 2020 15:39:50 +0300 Subject: [PATCH] update --- src/server/settings/torrent.go | 1 + src/server/torr/dbwrapper.go | 2 ++ src/server/torr/torrent.go | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/server/settings/torrent.go b/src/server/settings/torrent.go index 9092146..8c30e5a 100644 --- a/src/server/settings/torrent.go +++ b/src/server/settings/torrent.go @@ -19,6 +19,7 @@ type TorrentDB struct { Poster string `json:"poster,omitempty"` Timestamp int64 `json:"timestamp,omitempty"` + Size int64 `json:"size,omitempty"` Files []state.TorrentFileStat `json:"files,omitempty"` } diff --git a/src/server/torr/dbwrapper.go b/src/server/torr/dbwrapper.go index 18e5705..a90b3ad 100644 --- a/src/server/torr/dbwrapper.go +++ b/src/server/torr/dbwrapper.go @@ -29,6 +29,7 @@ func GetTorrentDB(hash metainfo.Hash) *Torrent { torr.Title = db.Title torr.Poster = db.Poster torr.Timestamp = db.Timestamp + torr.Size = db.Size torr.Stat = state.TorrentInDB return torr } @@ -49,6 +50,7 @@ func ListTorrentsDB() map[metainfo.Hash]*Torrent { torr.Title = db.Title torr.Poster = db.Poster torr.Timestamp = db.Timestamp + torr.Size = db.Size torr.Stat = state.TorrentInDB ret[torr.TorrentSpec.InfoHash] = torr } diff --git a/src/server/torr/torrent.go b/src/server/torr/torrent.go index a787442..f400372 100644 --- a/src/server/torr/torrent.go +++ b/src/server/torr/torrent.go @@ -26,6 +26,7 @@ type Torrent struct { Stat state.TorrentStat Timestamp int64 + Size int64 ///// *torrent.Torrent @@ -80,6 +81,7 @@ func NewTorrent(spec *torrent.TorrentSpec, bt *BTServer) (*Torrent, error) { torr.TorrentSpec = spec torr.expiredTime = time.Now().Add(time.Minute) torr.Timestamp = time.Now().Unix() + torr.Size = goTorrent.Length() go torr.watch() @@ -353,6 +355,7 @@ func (t *Torrent) Status() *state.TorrentStatus { st.Title = t.Title st.Poster = t.Poster st.Timestamp = t.Timestamp + st.TorrentSize = t.Size if t.TorrentSpec != nil { st.Hash = t.TorrentSpec.InfoHash.HexString() @@ -361,7 +364,7 @@ func (t *Torrent) Status() *state.TorrentStatus { st.Name = t.Torrent.Name() st.Hash = t.Torrent.InfoHash().HexString() st.LoadedSize = t.Torrent.BytesCompleted() - st.TorrentSize = t.Length() + st.TorrentSize = t.Torrent.Length() st.PreloadedBytes = t.PreloadedBytes st.PreloadSize = t.PreloadSize st.DownloadSpeed = t.DownloadSpeed