Fix download issues

This commit is contained in:
Ben Sarmiento
2023-11-06 02:26:46 +00:00
parent a39c72523d
commit 633e44298e
2 changed files with 11 additions and 8 deletions

View File

@@ -1,8 +1,8 @@
package chunk
import (
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"fmt"
"os"
@@ -144,7 +144,12 @@ func (m *Manager) GetChunk(object *torrent.File, offset, size int64) ([]byte, er
}
func buildRequestID(object *torrent.File, offset int64) (id RequestID) {
hex.Decode(id[:], []byte(object.Link))
fileID := object.Link
if fileID == "" {
fileID = object.Path
}
hash := sha256.Sum256([]byte(fileID))
copy(id[:16], hash[:16])
binary.BigEndian.PutUint64(id[16:], uint64(offset))
return
}