Fix missing value in serialized pause option

pull/54/merge
Tatsuhiro Tsujikawa 2013-03-03 13:17:49 +09:00
parent 1596e83a83
commit 910e40f128
2 changed files with 5 additions and 1 deletions

View File

@ -281,7 +281,8 @@ bool SessionSerializer::save(BufferedFile& fp) const
// PREF_PAUSE was removed from option, so save it here looking
// property separately.
if(rg->isPauseRequested()) {
if (fp.write(" ", 1) != 1 || fp.write(PREF_PAUSE->k) == 0 || fp.write("\n", 1) != 1) {
if (fp.write(" ", 1) != 1 || fp.write(PREF_PAUSE->k) == 0 ||
fp.write("=true\n", 6) != 6) {
return false;
}
}

View File

@ -45,6 +45,7 @@ void SessionSerializerTest::testSave()
option->put(PREF_DIR, "/tmp");
createRequestGroupForUri(result, option, uris);
CPPUNIT_ASSERT_EQUAL((size_t)5, result.size());
result[4]->getOption()->put(PREF_PAUSE, A2_V_TRUE);
option->put(PREF_MAX_DOWNLOAD_RESULT, "10");
SharedHandle<RequestGroupMan> rgman
(new RequestGroupMan(result, 1, option.get()));
@ -116,6 +117,8 @@ void SessionSerializerTest::testSave()
std::getline(ss, line);
CPPUNIT_ASSERT_EQUAL(std::string(" dir=/tmp"), line);
std::getline(ss, line);
CPPUNIT_ASSERT_EQUAL(std::string(" pause=true"), line);
std::getline(ss, line);
CPPUNIT_ASSERT(!ss);
#endif // defined(ENABLE_BITTORRENT) && defined(ENABLE_METALINK)
}