Merge pull request #25 from rumanzo/fixremaining

Fixremaining
This commit is contained in:
Alexey Kostin 2021-03-14 20:58:06 +03:00 committed by GitHub
commit 79f4dff753
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -220,7 +220,11 @@ func logic(key string, value map[string]interface{}, flags *Flags, chans *Channe
newstructure.QbtQueuePosition = position newstructure.QbtQueuePosition = position
newstructure.Started(value["started"].(int64)) newstructure.Started(value["started"].(int64))
newstructure.FinishedTime = int64(time.Since(time.Unix(value["completed_on"].(int64), 0)).Minutes()) 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.TotalUploaded = value["uploaded"].(int64)
newstructure.UploadRateLimit = value["upspeed"].(int64) newstructure.UploadRateLimit = value["upspeed"].(int64)
newstructure.IfTags(value["labels"]) newstructure.IfTags(value["labels"])

View File

@ -150,15 +150,20 @@ func (newstructure *NewTorrentStructure) FillMissing() {
newstructure.FillSizes() newstructure.FillSizes()
newstructure.FillSavePaths() newstructure.FillSavePaths()
if newstructure.Unfinished != nil { 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 { } else {
if newstructure.HasFiles { if newstructure.HasFiles {
newstructure.Pieces = newstructure.FillHaveFiles() newstructure.Pieces = newstructure.FillPiecesParted()
} else { } else {
newstructure.Pieces = newstructure.FillNotHaveFiles("1") newstructure.Pieces = newstructure.FillWholePieces("1")
} }
newstructure.PiecePriority = newstructure.Pieces
} }
newstructure.PiecePriority = newstructure.Pieces
} }
func (newstructure *NewTorrentStructure) FillSizes() { 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) var newpieces = make([]byte, 0, newstructure.NumPieces)
nchr, _ := strconv.Atoi(chr) nchr, _ := strconv.Atoi(chr)
for i := int64(0); i < newstructure.NumPieces; i++ { for i := int64(0); i < newstructure.NumPieces; i++ {
@ -213,7 +218,7 @@ func (newstructure *NewTorrentStructure) GetHash() (hash string) {
return return
} }
func (newstructure *NewTorrentStructure) FillHaveFiles() []byte { func (newstructure *NewTorrentStructure) FillPiecesParted() []byte {
var newpieces = make([]byte, 0, newstructure.NumPieces) var newpieces = make([]byte, 0, newstructure.NumPieces)
var allocation [][]int64 var allocation [][]int64
chrone, _ := strconv.Atoi("1") chrone, _ := strconv.Atoi("1")