mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
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:
+7
-1
@@ -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
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user