From 130c6a9c555a659e2ca2ff454940a060d0193cad Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 11 Nov 2009 05:28:28 +0000 Subject: [PATCH] fixed python binding typo in session_status and added some more documentation for file_storage --- ChangeLog | 1 + bindings/python/src/session.cpp | 2 +- docs/make_torrent.rst | 37 +++++++++++++++++++++++++++++++++ docs/manual.rst | 6 +++--- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f91f69344..2bb7ad038 100644 --- a/ChangeLog +++ b/ChangeLog @@ -104,6 +104,7 @@ release 0.14.7 * fixed create_torrent when passing in a path ending with / * fixed move_storage when source doesn't exist * fixed DHT state save bug for node-id + * fixed typo in python binding session_status struct release 0.14.6 diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index d82579d4d..c307ce5a9 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -210,7 +210,7 @@ void bind_session() #ifndef TORRENT_DISABLE_DHT .def_readonly("dht_nodes", &session_status::dht_nodes) - .def_readonly("dht_cache_nodes", &session_status::dht_node_cache) + .def_readonly("dht_node_cache", &session_status::dht_node_cache) .def_readonly("dht_torrents", &session_status::dht_torrents) .def_readonly("dht_global_nodes", &session_status::dht_global_nodes) .def_readonly("active_requests", &session_status::active_requests) diff --git a/docs/make_torrent.rst b/docs/make_torrent.rst index 860502a4e..3f37fe67b 100644 --- a/docs/make_torrent.rst +++ b/docs/make_torrent.rst @@ -189,6 +189,25 @@ The possible arreibutes are:: attribute_hidden attribute_executable +add_file +-------- + + :: + + void add_file(file_entry const& e); + void add_file(fs::path const& p, size_type size); + +Adds a file to the file storage. If more files than one are added, +certain restrictions to their paths apply. In a multi-file file +storage (torrent), all files must share the same root directory. + +That is, the first path element of all files must be the same. +This shared path element is also set to the name of the torrent. It +can be changed by calling ``set_name``. + +The built in functions to traverse a directory to add files will +make sure this requirement is fulfilled. + create_torrent ============== @@ -272,6 +291,24 @@ generate the flat file, use the bencode() function. It may be useful to add custom entries to the torrent file before bencoding it and saving it to disk. +If anything goes wrong during torrent generation, this function will return +an empty ``entry`` structure. You can test for this condition by querying the +type of the entry:: + + file_storage fs; + // add file ... + create_torrent t(fs); + // add trackers and piece hashes ... + e = t.generate(); + + if (e.type() == entry::undefined_t) + { + // something went wrong + } + +For instance, you cannot generate a torrent with 0 files in it. If you don't add +any files to the ``file_storage``, torrent generation will fail. + set_comment() ------------- diff --git a/docs/manual.rst b/docs/manual.rst index a8b4ba02a..79bf363d9 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -698,7 +698,7 @@ struct has the following members:: int unchoke_counter; int dht_nodes; - int dht_cache_nodes; + int dht_node_cache; int dht_torrents; int dht_global_nodes; std::vector active_requests; @@ -750,11 +750,11 @@ seconds until the next optimistic unchoke change and the start of the next unchoke interval. These numbers may be reset prematurely if a peer that is unchoked disconnects or becomes notinterested. -``dht_nodes``, ``dht_cache_nodes`` and ``dht_torrents`` are only available when +``dht_nodes``, ``dht_node_cache`` and ``dht_torrents`` are only available when built with DHT support. They are all set to 0 if the DHT isn't running. When the DHT is running, ``dht_nodes`` is set to the number of nodes in the routing table. This number only includes *active* nodes, not cache nodes. The -``dht_cache_nodes`` is set to the number of nodes in the node cache. These nodes +``dht_node_cache`` is set to the number of nodes in the node cache. These nodes are used to replace the regular nodes in the routing table in case any of them becomes unresponsive.