Don't write Lox context to database in simulation

This commit is contained in:
Vecna 2024-05-31 10:58:26 -04:00
parent 43aff6c750
commit a19a8bb3c2
2 changed files with 28 additions and 22 deletions

View File

@ -45,3 +45,6 @@ sha1 = "0.10"
[dependencies.chrono] [dependencies.chrono]
version = "0.4.38" version = "0.4.38"
features = ["serde"] features = ["serde"]
[features]
simulation = []

View File

@ -29,6 +29,8 @@ impl DB {
// Writes the Lox context to the lox database with "context_%Y-%m-%d_%H:%M:%S" as the // Writes the Lox context to the lox database with "context_%Y-%m-%d_%H:%M:%S" as the
// database key // database key
pub fn write_context(&mut self, context: lox_context::LoxServerContext) { pub fn write_context(&mut self, context: lox_context::LoxServerContext) {
#[cfg(not(feature = "simulation"))]
{
let date = Local::now().format("context_%Y-%m-%d_%H:%M:%S").to_string(); let date = Local::now().format("context_%Y-%m-%d_%H:%M:%S").to_string();
/* Uncomment to generate test file for this function after making changes to lox library /* Uncomment to generate test file for this function after making changes to lox library
let file = OpenOptions::new() let file = OpenOptions::new()
@ -52,6 +54,7 @@ impl DB {
IVec::from(json_result) IVec::from(json_result)
); );
} }
}
// If roll_back_date is empty, opens the most recent entry in the lox database or if none exists, creates a // If roll_back_date is empty, opens the most recent entry in the lox database or if none exists, creates a
// new database. If roll_back_date is not empty, use the specified date to roll back to a previous lox-context // new database. If roll_back_date is not empty, use the specified date to roll back to a previous lox-context