From 8ee5268123dc1d197e958882962f2e329943b1cc Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 20 Mar 2010 02:41:36 +0000 Subject: [PATCH] disable including 'mtime' in new torrents by default --- docs/make_torrent.rst | 12 ++++++++++-- include/libtorrent/create_torrent.hpp | 6 +++++- src/create_torrent.cpp | 11 +++++++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/docs/make_torrent.rst b/docs/make_torrent.rst index 3f37fe67b..5cd325bc8 100644 --- a/docs/make_torrent.rst +++ b/docs/make_torrent.rst @@ -217,7 +217,7 @@ The ``create_torrent`` class has the following synopsis:: 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(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(torrent_info const& ti); @@ -278,6 +278,14 @@ merkle not grow with more pieces. When this option is specified, it is 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() ---------- diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index 1a9ebba40..9ad1ece68 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -66,7 +66,7 @@ namespace libtorrent 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 , int pad_file_limit = -1, int flags = optimize); @@ -139,6 +139,10 @@ namespace libtorrent // if set to one, a merkle torrent will be generated bool m_merkle_torrent:1; + + // if set, include the 'mtime' modification time in the + // torrent file + bool m_include_mtime:1; }; namespace detail diff --git a/src/create_torrent.cpp b/src/create_torrent.cpp index eb525630a..8ed198c9c 100644 --- a/src/create_torrent.cpp +++ b/src/create_torrent.cpp @@ -113,6 +113,7 @@ namespace libtorrent , m_multifile(fs.num_files() > 1) , m_private(false) , m_merkle_torrent(flags & merkle) + , m_include_mtime(flags & modification_time) { TORRENT_ASSERT(fs.num_files() > 0); @@ -278,7 +279,10 @@ namespace libtorrent 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; if (m_files.at(0).pad_file || m_files.at(0).hidden_attribute @@ -311,7 +315,10 @@ namespace libtorrent { files.list().push_back(entry()); 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; entry& path_e = file_e["path"];