From 0009754f1e10dfc60a52549ab15329f173cdf74b Mon Sep 17 00:00:00 2001 From: Alexey Kostin Date: Fri, 5 Mar 2021 23:28:42 +0300 Subject: [PATCH 1/4] Revert "fix piecepriotiry structure" This reverts commit 45d06fac8bbcd0c62aa0cf318c718716e5a56081. --- libtorrent/torrent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libtorrent/torrent.go b/libtorrent/torrent.go index 30bf335..d78c75f 100644 --- a/libtorrent/torrent.go +++ b/libtorrent/torrent.go @@ -158,7 +158,7 @@ func (newstructure *NewTorrentStructure) FillMissing() { newstructure.Pieces = newstructure.FillNotHaveFiles("1") } } - newstructure.PiecePriority = newstructure.Pieces + newstructure.PiecePriority = newstructure.FillNotHaveFiles("1") } func (newstructure *NewTorrentStructure) FillSizes() { From 71c3b1aa661019590f4d032dde271a823dbc080c Mon Sep 17 00:00:00 2001 From: Alexey Kostin Date: Sun, 14 Mar 2021 15:36:53 +0300 Subject: [PATCH 2/4] total downloaded 0 for not completed torrents --- bt2qbt.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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"]) From 04a0b7c93c8210282d9fcbb1731e2ff44c9601a6 Mon Sep 17 00:00:00 2001 From: Alexey Kostin Date: Sun, 14 Mar 2021 16:47:31 +0300 Subject: [PATCH 3/4] Rename functions. New filling PiecePriority --- libtorrent/torrent.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libtorrent/torrent.go b/libtorrent/torrent.go index d78c75f..a5e4e24 100644 --- a/libtorrent/torrent.go +++ b/libtorrent/torrent.go @@ -150,15 +150,16 @@ func (newstructure *NewTorrentStructure) FillMissing() { newstructure.FillSizes() newstructure.FillSavePaths() if newstructure.Unfinished != nil { - newstructure.Pieces = newstructure.FillNotHaveFiles("0") + newstructure.Pieces = newstructure.FillWholePieces("0") + newstructure.PiecePriority = newstructure.FillPiecesParted() } 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.FillNotHaveFiles("1") } func (newstructure *NewTorrentStructure) FillSizes() { @@ -196,7 +197,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 +214,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") From c39b5b41a9761f4bc88a2c6a0525b3936edbd321 Mon Sep 17 00:00:00 2001 From: Alexey Kostin Date: Sun, 14 Mar 2021 17:41:05 +0300 Subject: [PATCH 4/4] Fix a bug --- libtorrent/torrent.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libtorrent/torrent.go b/libtorrent/torrent.go index a5e4e24..2435cdc 100644 --- a/libtorrent/torrent.go +++ b/libtorrent/torrent.go @@ -151,7 +151,11 @@ func (newstructure *NewTorrentStructure) FillMissing() { newstructure.FillSavePaths() if newstructure.Unfinished != nil { newstructure.Pieces = newstructure.FillWholePieces("0") - newstructure.PiecePriority = newstructure.FillPiecesParted() + if newstructure.HasFiles { + newstructure.PiecePriority = newstructure.FillPiecesParted() + } else { + newstructure.PiecePriority = newstructure.FillWholePieces("1") + } } else { if newstructure.HasFiles { newstructure.Pieces = newstructure.FillPiecesParted()