Browse Source

Fix missing value in serialized pause option

Tatsuhiro Tsujikawa 12 years ago
parent
commit
910e40f128
2 changed files with 5 additions and 1 deletions
  1. 2 1
      src/SessionSerializer.cc
  2. 3 0
      test/SessionSerializerTest.cc

+ 2 - 1
src/SessionSerializer.cc

@@ -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;
         }
       }

+ 3 - 0
test/SessionSerializerTest.cc

@@ -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)
 }