This commit is contained in:
YouROK
2020-11-19 15:39:50 +03:00
parent f5827b8424
commit d730c04c26
3 changed files with 7 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ type TorrentDB struct {
Poster string `json:"poster,omitempty"` Poster string `json:"poster,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"` Timestamp int64 `json:"timestamp,omitempty"`
Size int64 `json:"size,omitempty"`
Files []state.TorrentFileStat `json:"files,omitempty"` Files []state.TorrentFileStat `json:"files,omitempty"`
} }

View File

@@ -29,6 +29,7 @@ func GetTorrentDB(hash metainfo.Hash) *Torrent {
torr.Title = db.Title torr.Title = db.Title
torr.Poster = db.Poster torr.Poster = db.Poster
torr.Timestamp = db.Timestamp torr.Timestamp = db.Timestamp
torr.Size = db.Size
torr.Stat = state.TorrentInDB torr.Stat = state.TorrentInDB
return torr return torr
} }
@@ -49,6 +50,7 @@ func ListTorrentsDB() map[metainfo.Hash]*Torrent {
torr.Title = db.Title torr.Title = db.Title
torr.Poster = db.Poster torr.Poster = db.Poster
torr.Timestamp = db.Timestamp torr.Timestamp = db.Timestamp
torr.Size = db.Size
torr.Stat = state.TorrentInDB torr.Stat = state.TorrentInDB
ret[torr.TorrentSpec.InfoHash] = torr ret[torr.TorrentSpec.InfoHash] = torr
} }

View File

@@ -26,6 +26,7 @@ type Torrent struct {
Stat state.TorrentStat Stat state.TorrentStat
Timestamp int64 Timestamp int64
Size int64
///// /////
*torrent.Torrent *torrent.Torrent
@@ -80,6 +81,7 @@ func NewTorrent(spec *torrent.TorrentSpec, bt *BTServer) (*Torrent, error) {
torr.TorrentSpec = spec torr.TorrentSpec = spec
torr.expiredTime = time.Now().Add(time.Minute) torr.expiredTime = time.Now().Add(time.Minute)
torr.Timestamp = time.Now().Unix() torr.Timestamp = time.Now().Unix()
torr.Size = goTorrent.Length()
go torr.watch() go torr.watch()
@@ -353,6 +355,7 @@ func (t *Torrent) Status() *state.TorrentStatus {
st.Title = t.Title st.Title = t.Title
st.Poster = t.Poster st.Poster = t.Poster
st.Timestamp = t.Timestamp st.Timestamp = t.Timestamp
st.TorrentSize = t.Size
if t.TorrentSpec != nil { if t.TorrentSpec != nil {
st.Hash = t.TorrentSpec.InfoHash.HexString() st.Hash = t.TorrentSpec.InfoHash.HexString()
@@ -361,7 +364,7 @@ func (t *Torrent) Status() *state.TorrentStatus {
st.Name = t.Torrent.Name() st.Name = t.Torrent.Name()
st.Hash = t.Torrent.InfoHash().HexString() st.Hash = t.Torrent.InfoHash().HexString()
st.LoadedSize = t.Torrent.BytesCompleted() st.LoadedSize = t.Torrent.BytesCompleted()
st.TorrentSize = t.Length() st.TorrentSize = t.Torrent.Length()
st.PreloadedBytes = t.PreloadedBytes st.PreloadedBytes = t.PreloadedBytes
st.PreloadSize = t.PreloadSize st.PreloadSize = t.PreloadSize
st.DownloadSpeed = t.DownloadSpeed st.DownloadSpeed = t.DownloadSpeed