Fixed API loot_load_lists bugs.

The userlist path was being ignored, and the masterlist loaded again as
the userlist. The function now errors if either of the given paths does
not exist.
This commit is contained in:
Oliver Hamlet
2014-11-01 12:39:16 +00:00
parent 1dd8687e28
commit 6af3dbf6b1
2 changed files with 11 additions and 4 deletions
+7 -1
View File
@@ -303,6 +303,9 @@ LOOT_API unsigned int loot_load_lists(loot_db db, const char * const masterlistP
// We don't want to update the masterlist too.
temp.MetadataList::Load(masterlistPath);
}
else {
return c_error(loot_error_path_not_found, std::string("The given masterlist path does not exist: ") + masterlistPath);
}
}
catch (std::exception& e) {
return c_error(loot_error_parse_fail, e.what());
@@ -311,7 +314,10 @@ LOOT_API unsigned int loot_load_lists(loot_db db, const char * const masterlistP
try {
if (userlistPath != nullptr) {
if (boost::filesystem::exists(userlistPath)) {
userTemp.Load(masterlistPath);
userTemp.Load(userlistPath);
}
else {
return c_error(loot_error_path_not_found, std::string("The given userlist path does not exist: ") + userlistPath);
}
}
}
+4 -3
View File
@@ -149,12 +149,13 @@ TEST_F(OblivionAPIOperationsTest, LoadLists) {
EXPECT_EQ(loot_error_invalid_args, loot_load_lists(NULL, masterlistPath.string().c_str(), NULL));
EXPECT_EQ(loot_error_invalid_args, loot_load_lists(db, NULL, NULL));
EXPECT_EQ(loot_error_path_not_found, loot_load_lists(db, masterlistPath.string().c_str(), NULL));
bool updated;
ASSERT_EQ(loot_ok, loot_update_masterlist(db, masterlistPath.string().c_str(), "https://github.com/loot/oblivion.git", "master", &updated));
EXPECT_EQ(loot_error_path_not_found, loot_load_lists(db, masterlistPath.string().c_str(), NULL));
ASSERT_NO_THROW(boost::filesystem::copy(masterlistPath, userlistPath));
EXPECT_EQ(loot_error_path_not_found, loot_load_lists(db, masterlistPath.string().c_str(), userlistPath.string().c_str()));
ASSERT_NO_THROW(boost::filesystem::copy(masterlistPath, userlistPath));
EXPECT_EQ(loot_ok, loot_load_lists(db, masterlistPath.string().c_str(), userlistPath.string().c_str()));
}
TEST_F(OblivionAPIOperationsTest, EvalLists) {