Skip to content

Commit

Permalink
session-changes - Fixed off-by-one. URL decode magnet uri.
Browse files Browse the repository at this point in the history
  • Loading branch information
masterwok committed Aug 10, 2018
1 parent a6855c4 commit 57a6cd8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.security.InvalidParameterException
* This class is used to control a torrent download session.
*/
@Suppress("MemberVisibilityCanBePrivate", "unused")
class TorrentSession(
open class TorrentSession(
private val torrentSessionOptions: TorrentSessionOptions
) {
companion object {
Expand Down Expand Up @@ -150,7 +150,7 @@ class TorrentSession(
largestFileUri = torrentHandle.getLargestFileUri(torrentSessionOptions.downloadLocation)
saveLocationUri = Uri.fromFile(torrentSessionOptions.downloadLocation)
bencode = torrentHandle.getBencode()
magnetUri = Uri.parse(torrentHandle.makeMagnetUri())
magnetUri = Uri.parse(URLDecoder.decode(torrentHandle.makeMagnetUri(), "utf-8"))

if (torrentSessionOptions.onlyDownloadLargestFile) {
torrentHandle.ignoreAllFiles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TorrentSessionBuffer constructor(
/**
* The total number of pieces.
*/
val pieceCount = (endIndex - startIndex) + 1
val pieceCount = if (startIndex == 0 && endIndex == 0) 0 else (endIndex - startIndex) + 1

/**
* The number of pieces downloaded.
Expand Down

0 comments on commit 57a6cd8

Please sign in to comment.