diff --git a/src/api/api.cpp b/src/api/api.cpp index 6c8b910c..4d3cf3b6 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -482,6 +482,8 @@ LOOT_API unsigned int loot_update_masterlist(loot_db db, bool * const updated) { if (db == nullptr || masterlistPath == nullptr || remoteURL == nullptr || remoteBranch == nullptr || updated == nullptr) return c_error(loot_error_invalid_args, "Null pointer passed."); + if (!boost::filesystem::is_directory(boost::filesystem::path(masterlistPath).parent_path())) + return c_error(loot_error_invalid_args, "Given masterlist path \"" + std::string(masterlistPath) + "\" does not have a valid parent directory."); *updated = false; diff --git a/src/tests/api/api.h b/src/tests/api/api.h index 18306546..06bfcc6e 100644 --- a/src/tests/api/api.h +++ b/src/tests/api/api.h @@ -152,8 +152,8 @@ TEST_F(OblivionAPIOperationsTest, UpdateMasterlist) { EXPECT_EQ(loot_error_invalid_args, loot_update_masterlist(db, masterlistPath.string().c_str(), "https://github.com/loot/oblivion.git", NULL, &updated)); EXPECT_EQ(loot_error_invalid_args, loot_update_masterlist(db, masterlistPath.string().c_str(), "https://github.com/loot/oblivion.git", "master", NULL)); - EXPECT_EQ(loot_error_git_error, loot_update_masterlist(db, ";//\?", "https://github.com/loot/oblivion.git", "master", &updated)); - EXPECT_EQ(loot_error_git_error, loot_update_masterlist(db, "", "https://github.com/loot/oblivion.git", "master", &updated)); + EXPECT_EQ(loot_error_invalid_args, loot_update_masterlist(db, ";//\?", "https://github.com/loot/oblivion.git", "master", &updated)); + EXPECT_EQ(loot_error_invalid_args, loot_update_masterlist(db, "", "https://github.com/loot/oblivion.git", "master", &updated)); EXPECT_EQ(loot_error_git_error, loot_update_masterlist(db, masterlistPath.string().c_str(), "https://github.com/loot/oblivion-does-not-exist.git", "master", &updated)); EXPECT_EQ(loot_error_git_error, loot_update_masterlist(db, masterlistPath.string().c_str(), "https://github.com/loot/oblivion.git", "missing-branch", &updated)); EXPECT_EQ(loot_error_git_error, loot_update_masterlist(db, masterlistPath.string().c_str(), "https://github.com/loot/oblivion.git", "", &updated));