Why do we need to Align File to Piece Boundary?
A .torrent file is a file that contains basic information in a well defined format, about a file or set of files. BitTorrent clients exchange these files according to this information. The clients do not transfer files by files but by pieces which have the same size. At the creation time of a torrent, all the files in the torrent are virtually concatenated and then the resulting data chunk is split into evenly sized pieces, of a size appointed by the torrent making application and indicated in the torrent file. If there is more than one file in the torrent, there might be some pieces containing the end of file A and at the same time the beginning of file B. As a result, although all the content in file A is downloaded, the status of the torrent task might keep permanent “99.9% finished” because some content from file B in this piece has not been downloaded. To resolve this problem, we have made every piece only contain content from the same file. This function was implemented by the “Align File to Piece Boundary” function. This feature, also was meant to support concurrent downloading from different sources, such as eD2K, additionally to BitTorrent, for any particular torrent.
<html><br /></html>
How to Align File to Piece Boundary?
If the last chunk of a file is too small to be a full piece, than we add a padding file into the torrent that is the exact size of the remaining unoccupied space in the piece, just behind this file. In this last piece, there will be only contents from this file and the padding file and also the padding file will end at the exact end of the piece thus being aligned to the piece boundary. This way every initial file is separately contained in different sets of pieces and no piece will overlap two of the initial files. Also, the “99.9% finished” problem will be gone. When communicating with each others, BitComet clients (version 0.85 or above) conceal and skip these padding files. Since all the versions from v.0.85 hold the algorithm for padding, the clients don't have to actually download these files but instead can only calculate the padding and skip downloading the padding files.
<html><br /></html>
How to enable Align File to Piece Boundary?
This function is enabled by default when you make a torrent with BitComet (version 0.85 or above). The option for enabling/disabling this function ca be found in the torrent making dialog box. See Making torrents with BitComet.