+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,21 +314,27 @@ func list() {
}

for _, t := range Storage.GetAll() {
if t.Info == nil {
continue
}
mask := t.PiecesMask()
downloadedPieces := 0
for _, b := range mask {
downloadedPieces += bits.OnesCount8(b)
}
full := t.Info.FileSize - t.Info.HeaderSize
downloaded := uint64(downloadedPieces*int(t.Info.PieceSize)) - t.Info.HeaderSize
if uint64(downloadedPieces*int(t.Info.PieceSize)) < t.Info.HeaderSize { // 0 if header not fully downloaded
downloaded = 0
}
if downloaded > full { // cut not full last piece
downloaded = full
var strDownloaded, strFull, description = "0 Bytes", "???", "???"
completed := false
if t.Info != nil {
mask := t.PiecesMask()
downloadedPieces := 0
for _, b := range mask {
downloadedPieces += bits.OnesCount8(b)
}
full := t.Info.FileSize - t.Info.HeaderSize
downloaded := uint64(downloadedPieces*int(t.Info.PieceSize)) - t.Info.HeaderSize
if uint64(downloadedPieces*int(t.Info.PieceSize)) < t.Info.HeaderSize { // 0 if header not fully downloaded
downloaded = 0
}
if downloaded > full { // cut not full last piece
downloaded = full
}
completed = downloaded == full

strDownloaded = storage.ToSz(downloaded)
strFull = storage.ToSz(full)
description = t.Info.Description.Value
}

var dow, upl, num uint64
Expand All @@ -338,9 +344,9 @@ func list() {
num++
}

table = append(table, []string{hex.EncodeToString(t.BagID), t.Info.Description.Value,
storage.ToSz(downloaded), storage.ToSz(full), fmt.Sprint(num),
storage.ToSpeed(dow), storage.ToSpeed(upl), fmt.Sprint(downloaded == full)})
table = append(table, []string{hex.EncodeToString(t.BagID), description,
strDownloaded, strFull, fmt.Sprint(num),
storage.ToSpeed(dow), storage.ToSpeed(upl), fmt.Sprint(completed)})
}

if len(table) > 1 {
Expand Down
4 changes: 2 additions & 2 deletions storage/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@ func (s *Server) handleRLDPQuery(peer *overlay.RLDPWrapper) func(transfer []byte
} else if len(lastPieces) > 0 {
mask := t.PiecesMask()
var newPieces []int32
for i := 0; i < len(lastPieces); i++ {
for i := 0; i < len(mask); i++ {
for j := 0; j < 8; j++ {
if mask[i]&(1<<j) > 0 && lastPieces[i]&(1<<j) == 0 {
if mask[i]&(1<<j) > 0 && (i >= len(lastPieces) || lastPieces[i]&(1<<j) == 0) {
newPieces = append(newPieces, int32(i*8+j))
}
}
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载