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.Started(value["started"].(int64))
newstructure.FinishedTime = int64(time.Since(time.Unix(value["completed_on"].(int64), 0)).Minutes())
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"])

View File

@ -150,16 +150,21 @@ 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
}
}
func (newstructure *NewTorrentStructure) FillSizes() {
newstructure.fileSizes = 0
@ -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")