Sandro Jijavadze
Sandro Jijavadze

Reputation: 57

Does the last piece of torrent correspond to the last piece of last file?

I am trying to download multiple torrents where I want last pieces of .mp4 files. I can't specifically target specific parts of specific files, but for example,if my torrent contains 3 files:

1.mp4 2.mp4 3.mp4

is the last piece of torrent same as last piece of the 3.mp4 file? So that, by downloading the last piece I will be downlaoding the last piece of 3.mp4 file. and is there a way to target last pieces of 2.mp4 and 1.mp4 as well? Thank you.

Upvotes: 2

Views: 700

Answers (1)

Encombe
Encombe

Reputation: 2090

Is the last piece of torrent same as last piece of the 3.mp4 file? So that, by downloading the last piece I will be downlaoding the last piece of 3.mp4 file.

Yes

Is there a way to target last pieces of 2.mp4 and 1.mp4 as well?

Yes

When a torrent is created, all files in it is concatenated together and then chunked up in pieces.

example:
Files  |-------------------#1|----------------#2|---------------------------#3|
Pieces |--0|--1|--2|--3|--4|--5|--6|--7|--8|--9|-10|-11|-12|-13|-14|-15|-16|17|
  • All pieces has the same length except the last one.
  • A file has one or more pieces.
  • A piece may contain (parts from) more than one file.
  • It's very rare that internal file and piece boundaries align (except if padding files is used).
  • A file in a multi-file torrent almost always has a piece shared with another file.

In the metadata from the .torrent file there is; the piece size, file sizes and and the exact order of the files.

The files are ordered as they appear on the files list in the .torrent file.
The order is decided by the torrent creator and my be any arbitrary order. File size, order on disk, alphabetical, random,creation date, name length, etc, etc

From that data, it's possible to calculate exact what piece and offset a specific file ends.

Upvotes: 2

Related Questions