disable including 'mtime' in new torrents by default

This commit is contained in:
Arvid Norberg 2010-03-20 02:41:36 +00:00
parent 9435e84644
commit 8ee5268123
3 changed files with 24 additions and 5 deletions

View File

@ -217,7 +217,7 @@ The ``create_torrent`` class has the following synopsis::
struct create_torrent struct create_torrent
{ {
enum { optimize = 1, merkle = 2 }; enum { optimize = 1, merkle = 2, modification_time = 4 };
create_torrent(file_storage& fs, int piece_size = 0, int pad_size_limit = -1, int flags = optimize); create_torrent(file_storage& fs, int piece_size = 0, int pad_size_limit = -1, int flags = optimize);
create_torrent(torrent_info const& ti); create_torrent(torrent_info const& ti);
@ -244,7 +244,7 @@ create_torrent()
:: ::
enum { optimize = 1, merkle = 2 }; enum { optimize = 1, merkle = 2, modification_time = 4 };
create_torrent(file_storage& fs, int piece_size = 0, int pad_size_limit = -1, int flags = optimize); create_torrent(file_storage& fs, int piece_size = 0, int pad_size_limit = -1, int flags = optimize);
create_torrent(torrent_info const& ti); create_torrent(torrent_info const& ti);
@ -278,6 +278,14 @@ merkle
not grow with more pieces. When this option is specified, it is not grow with more pieces. When this option is specified, it is
recommended to have a fairly small piece size, say 64 kiB. recommended to have a fairly small piece size, say 64 kiB.
modification_time
This will include the file modification time as part of the torrent.
This is not enabled by default, as it might cause problems when you
create a torrent from separate files with the same content, hoping to
yield the same info-hash. If the files have different modification times,
with this option enabled, you would get different info-hashes for the
files.
generate() generate()
---------- ----------

View File

@ -66,7 +66,7 @@ namespace libtorrent
struct TORRENT_EXPORT create_torrent struct TORRENT_EXPORT create_torrent
{ {
enum { optimize = 1, merkle = 2 }; enum { optimize = 1, merkle = 2, modification_time = 4 };
create_torrent(file_storage& fs, int piece_size = 0 create_torrent(file_storage& fs, int piece_size = 0
, int pad_file_limit = -1, int flags = optimize); , int pad_file_limit = -1, int flags = optimize);
@ -139,6 +139,10 @@ namespace libtorrent
// if set to one, a merkle torrent will be generated // if set to one, a merkle torrent will be generated
bool m_merkle_torrent:1; bool m_merkle_torrent:1;
// if set, include the 'mtime' modification time in the
// torrent file
bool m_include_mtime:1;
}; };
namespace detail namespace detail

View File

@ -113,6 +113,7 @@ namespace libtorrent
, m_multifile(fs.num_files() > 1) , m_multifile(fs.num_files() > 1)
, m_private(false) , m_private(false)
, m_merkle_torrent(flags & merkle) , m_merkle_torrent(flags & merkle)
, m_include_mtime(flags & modification_time)
{ {
TORRENT_ASSERT(fs.num_files() > 0); TORRENT_ASSERT(fs.num_files() > 0);
@ -278,7 +279,10 @@ namespace libtorrent
if (!m_multifile) if (!m_multifile)
{ {
info["mtime"] = m_files.at(0).mtime; if (m_include_mtime)
{
info["mtime"] = m_files.at(0).mtime;
}
info["length"] = m_files.at(0).size; info["length"] = m_files.at(0).size;
if (m_files.at(0).pad_file if (m_files.at(0).pad_file
|| m_files.at(0).hidden_attribute || m_files.at(0).hidden_attribute
@ -311,7 +315,10 @@ namespace libtorrent
{ {
files.list().push_back(entry()); files.list().push_back(entry());
entry& file_e = files.list().back(); entry& file_e = files.list().back();
file_e["mtime"] = i->mtime; if (m_include_mtime)
{
file_e["mtime"] = i->mtime;
}
file_e["length"] = i->size; file_e["length"] = i->size;
entry& path_e = file_e["path"]; entry& path_e = file_e["path"];