diff --git a/bt2qbt.go b/bt2qbt.go index 9ec0c70..b47e26e 100644 --- a/bt2qbt.go +++ b/bt2qbt.go @@ -220,7 +220,11 @@ func logic(key string, value map[string]interface{}, flags *Flags, chans *Channe newstructure.QbtQueuePosition = position newstructure.Started(value["started"].(int64)) newstructure.FinishedTime = int64(time.Since(time.Unix(value["completed_on"].(int64), 0)).Minutes()) - newstructure.TotalDownloaded = value["downloaded"].(int64) + if value["completed_on"].(int64) == 0 { + newstructure.TotalDownloaded = 0 + } else { + newstructure.TotalDownloaded = value["downloaded"].(int64) + } newstructure.TotalUploaded = value["uploaded"].(int64) newstructure.UploadRateLimit = value["upspeed"].(int64) newstructure.IfTags(value["labels"]) diff --git a/libtorrent/torrent.go b/libtorrent/torrent.go index 30bf335..2435cdc 100644 --- a/libtorrent/torrent.go +++ b/libtorrent/torrent.go @@ -150,15 +150,20 @@ func (newstructure *NewTorrentStructure) FillMissing() { newstructure.FillSizes() newstructure.FillSavePaths() if newstructure.Unfinished != nil { - newstructure.Pieces = newstructure.FillNotHaveFiles("0") + newstructure.Pieces = newstructure.FillWholePieces("0") + if newstructure.HasFiles { + newstructure.PiecePriority = newstructure.FillPiecesParted() + } else { + newstructure.PiecePriority = newstructure.FillWholePieces("1") + } } else { if newstructure.HasFiles { - newstructure.Pieces = newstructure.FillHaveFiles() + newstructure.Pieces = newstructure.FillPiecesParted() } else { - newstructure.Pieces = newstructure.FillNotHaveFiles("1") + newstructure.Pieces = newstructure.FillWholePieces("1") } + newstructure.PiecePriority = newstructure.Pieces } - newstructure.PiecePriority = newstructure.Pieces } func (newstructure *NewTorrentStructure) FillSizes() { @@ -196,7 +201,7 @@ func (newstructure *NewTorrentStructure) FillSizes() { } } -func (newstructure *NewTorrentStructure) FillNotHaveFiles(chr string) []byte { +func (newstructure *NewTorrentStructure) FillWholePieces(chr string) []byte { var newpieces = make([]byte, 0, newstructure.NumPieces) nchr, _ := strconv.Atoi(chr) for i := int64(0); i < newstructure.NumPieces; i++ { @@ -213,7 +218,7 @@ func (newstructure *NewTorrentStructure) GetHash() (hash string) { return } -func (newstructure *NewTorrentStructure) FillHaveFiles() []byte { +func (newstructure *NewTorrentStructure) FillPiecesParted() []byte { var newpieces = make([]byte, 0, newstructure.NumPieces) var allocation [][]int64 chrone, _ := strconv.Atoi("1")