From 40f6afc2f872c41d9456be086dd65fc37c6c63e7 Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 18 Feb 2016 20:52:09 -0500 Subject: [PATCH] save and restore storage allocation mode in resume data --- docs/manual.rst | 7 ++----- src/read_resume_data.cpp | 7 +++++-- src/torrent.cpp | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/manual.rst b/docs/manual.rst index 0a3becd83..58eef1341 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -486,11 +486,8 @@ The file format is a bencoded dictionary containing the following fields: | | +-------------+--------------------------------------------+ | | | | +--------------------------+--------------------------------------------------------------+ -| ``allocation`` | The allocation mode for the storage. Can be either ``full`` | -| | or ``compact``. If this is full, the file sizes and | -| | timestamps are disregarded. Pieces are assumed not to have | -| | moved around even if the files have been modified after the | -| | last resume data checkpoint. | +| ``allocation`` | The allocation mode for the storage. Can be either | +| | ``allocate`` or ``sparse``. | +--------------------------+--------------------------------------------------------------+ storage allocation diff --git a/src/read_resume_data.cpp b/src/read_resume_data.cpp index 689794fb2..ac12a3bb9 100644 --- a/src/read_resume_data.cpp +++ b/src/read_resume_data.cpp @@ -68,9 +68,12 @@ namespace libtorrent add_torrent_params read_resume_data(bdecode_node const& rd, error_code& ec) { - // TODO: 4 where is "allocation" read? - add_torrent_params ret; + if (bdecode_node alloc = rd.dict_find_string("allocation")) + { + ret.storage_mode = (alloc.string_value() == "allocate" + || alloc.string_value() == "full") ? storage_mode_allocate : storage_mode_sparse; + } if (rd.dict_find_string_value("file-format") != "libtorrent resume file") diff --git a/src/torrent.cpp b/src/torrent.cpp index ca300c9fe..1f21f7bbe 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -2105,7 +2105,6 @@ namespace libtorrent inc_refcount("check_fastresume"); // async_check_files will gut links - // TODO: 4 check_fastresume should probably be renamed check_files. m_ses.disk_thread().async_check_files( m_storage.get(), m_add_torrent_params ? m_add_torrent_params.get() : NULL , links, boost::bind(&torrent::on_resume_data_checked @@ -6713,6 +6712,8 @@ namespace libtorrent ret["file-format"] = "libtorrent resume file"; ret["file-version"] = 1; ret["libtorrent-version"] = LIBTORRENT_VERSION; + ret["allocation"] = m_storage_mode == storage_mode_allocate + ? "allocate" : "sparse"; ret["total_uploaded"] = m_total_uploaded; ret["total_downloaded"] = m_total_downloaded;