add fav + opti

This commit is contained in:
2026-05-21 10:47:49 +02:00
parent 72ad88e888
commit 46dfa0fd49
3 changed files with 103 additions and 71 deletions

View File

@ -30,6 +30,14 @@ impl Database {
PRAGMA foreign_keys=ON;",
)?;
conn.execute_batch(
"CREATE TABLE IF NOT EXISTS schema_version (version INTEGER NOT NULL DEFAULT 1);",
)?;
conn.execute(
"INSERT INTO schema_version (version) SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM schema_version)",
[],
)?;
conn.execute(
"CREATE TABLE IF NOT EXISTS history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
@ -296,12 +304,14 @@ impl Database {
}
pub fn clear_history(&self) -> Result<(), Box<dyn Error>> {
self.conn.execute("DELETE FROM history", [])?;
let images_dir = Path::new(&self.dir_path).join("images");
if images_dir.exists() {
fs::remove_dir_all(&images_dir)?;
}
fs::create_dir_all(&images_dir)?;
self.conn.execute("DELETE FROM history", [])?;
Ok(())
}
}