Skip to content

Commit f79bd8a

Browse files
committed
fix db
1 parent 8c48b21 commit f79bd8a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/database.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::{
2+
env,
23
io::Cursor,
4+
path::Path,
35
time::{Duration, SystemTime, UNIX_EPOCH},
46
};
57

@@ -10,8 +12,13 @@ use rusqlite::{Connection, params};
1012
use crate::clipboard::ClipBoardContentType;
1113

1214
pub fn initialise_database() -> Connection {
13-
let conn =
14-
Connection::open("clipboard.db").expect("Couldn't open a connection to 'clipboard.db'");
15+
let current_exe = env::current_exe()
16+
.ok()
17+
.and_then(|x| x.parent().map(|x| x.to_path_buf()))
18+
.unwrap_or(Path::new("/tmp").to_path_buf());
19+
20+
let conn = Connection::open(current_exe.join(Path::new("clipboard.db")))
21+
.expect("Couldn't open a connection to 'clipboard.db'");
1522

1623
if !conn
1724
.table_exists(None, "clipboard_entries")

0 commit comments

Comments
 (0)