diff --git a/src/part_file.cpp b/src/part_file.cpp index f5df28fbe..e2baba1f3 100644 --- a/src/part_file.cpp +++ b/src/part_file.cpp @@ -350,6 +350,8 @@ namespace libtorrent if (m_piece_map.empty()) { + m_file.close(); + // if we don't have any pieces left in the // part file, remove it std::string p = combine_path(m_path, m_name); diff --git a/test/test_part_file.cpp b/test/test_part_file.cpp index cb0c10acb..93e516c16 100644 --- a/test/test_part_file.cpp +++ b/test/test_part_file.cpp @@ -126,7 +126,9 @@ int test_main() // we just removed the last piece. The partfile does not // contain anything anymore, it should have deleted itself - TEST_CHECK(!exists(combine_path(combine_path(cwd, "partfile_test_dir2"), "partfile.parts"))); + TEST_CHECK(!exists(combine_path(combine_path(cwd, "partfile_test_dir2"), "partfile.parts"), ec)); + TEST_CHECK(!ec); + if (ec) fprintf(stderr, "exists: %s\n", ec.message().c_str()); output.close();