mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Decouple clearing condition cache from evaluating general messages
This commit is contained in:
@@ -52,6 +52,14 @@ bool Database::Evaluate(const std::string& condition) const {
|
||||
}
|
||||
}
|
||||
|
||||
void Database::ClearConditionCache() {
|
||||
try {
|
||||
return database_->clear_condition_cache();
|
||||
} catch (const ::rust::Error& e) {
|
||||
std::rethrow_exception(mapError(e));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Database::GetKnownBashTags() const {
|
||||
try {
|
||||
return convert<std::string>(database_->known_bash_tags());
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
|
||||
bool Evaluate(const std::string& condition) const override;
|
||||
|
||||
void ClearConditionCache() override;
|
||||
|
||||
std::vector<std::string> GetKnownBashTags() const override;
|
||||
|
||||
std::vector<Message> GetGeneralMessages(
|
||||
|
||||
@@ -94,6 +94,15 @@ impl Database {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn clear_condition_cache(&self) -> Result<(), VerboseError> {
|
||||
self.0
|
||||
.write()
|
||||
.map_err(DatabaseLockPoisonError::from)?
|
||||
.clear_condition_cache();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn known_bash_tags(&self) -> Result<Vec<String>, VerboseError> {
|
||||
Ok(self
|
||||
.0
|
||||
|
||||
@@ -266,6 +266,8 @@ mod ffi {
|
||||
|
||||
pub fn evaluate(&self, condition: &str) -> Result<bool>;
|
||||
|
||||
pub fn clear_condition_cache(&self) -> Result<()>;
|
||||
|
||||
pub fn known_bash_tags(&self) -> Result<Vec<String>>;
|
||||
|
||||
pub fn general_messages(&self, evaluate_conditions: bool) -> Result<Vec<Message>>;
|
||||
|
||||
@@ -277,6 +277,21 @@ TEST_P(DatabaseInterfaceTest, evaluateShouldReturnFalseIfTheConditionIsFalse) {
|
||||
EXPECT_FALSE(handle_->GetDatabase().Evaluate("file(\"missing.esp\")"));
|
||||
}
|
||||
|
||||
TEST_P(DatabaseInterfaceTest,
|
||||
clearConditionCacheShouldCauseConditionsToBeEvaluatedFromScratch) {
|
||||
const auto condition = "file(\"Blank.esp\")";
|
||||
|
||||
EXPECT_TRUE(handle_->GetDatabase().Evaluate(condition));
|
||||
|
||||
std::filesystem::remove(dataPath / "Blank.esp");
|
||||
|
||||
EXPECT_TRUE(handle_->GetDatabase().Evaluate(condition));
|
||||
|
||||
handle_->GetDatabase().ClearConditionCache();
|
||||
|
||||
EXPECT_FALSE(handle_->GetDatabase().Evaluate(condition));
|
||||
}
|
||||
|
||||
TEST_P(DatabaseInterfaceTest,
|
||||
getGroupsShouldReturnAllGroupsListedInTheLoadedMetadata) {
|
||||
ASSERT_NO_THROW(GenerateMasterlist());
|
||||
|
||||
Reference in New Issue
Block a user