Skip to content

Commit

Permalink
fix(concurrency): can now use tally across multiple processes
Browse files Browse the repository at this point in the history
  • Loading branch information
uhryniuk committed Nov 14, 2024
1 parent 4066a4b commit f0740f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tally-cli"
version = "0.1.3"
version = "0.1.4"
authors = ["Dylan Uhryniuk <[email protected]>"]
license = "MIT"
repository = "https://github.com/uhryniuk/tally"
Expand Down
9 changes: 6 additions & 3 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ pub struct Database {

impl Database {
pub fn new(name: &str) -> Result<Database> {
let db = Database {
conn: sqlite::Connection::open_thread_safe(name)?,
};
// Create process and thread safe connection
let mut connection = sqlite::Connection::open_thread_safe(name).expect("ORPS");
connection.set_busy_timeout(5_000_000)?;
connection.execute("PRAGMA journal_mode = WAL;")?;

let db = Database { conn: connection };
db.init_database()?;
db.get_default_counter()?;
Ok(db)
Expand Down

0 comments on commit f0740f2

Please sign in to comment.