use tmpfile demo db
This commit is contained in:
parent
480d686b1c
commit
da7e037562
10
src/main.rs
10
src/main.rs
@ -92,7 +92,15 @@ fn rocket() -> _ {
|
||||
let args = Args::parse();
|
||||
|
||||
let db_url = if args.demo {
|
||||
"file:memdb1?mode=memory&cache=shared".to_string()
|
||||
// Use a temporary file for demo mode instead of in-memory database
|
||||
let temp_db = "/tmp/rss-reader-temp-db.sqlite";
|
||||
// Delete the file if it exists to start fresh
|
||||
if std::path::Path::new(temp_db).exists() {
|
||||
std::fs::remove_file(temp_db).expect("Failed to remove old temporary database");
|
||||
}
|
||||
// Create the new database file
|
||||
std::fs::File::create(temp_db).expect("Failed to create temporary database file");
|
||||
format!("sqlite:{}", temp_db)
|
||||
} else {
|
||||
let database = args
|
||||
.database
|
||||
|
Loading…
Reference in New Issue
Block a user