Browse Source
Spelling and small adjustments
Signed-off-by: BlackDex <black.dex@gmail.com>
pull/4906/head
BlackDex
8 months ago
No known key found for this signature in database
GPG Key ID: 58C80A2AA6C765E1
2 changed files with
6 additions and
4 deletions
-
src/db/mod.rs
-
src/main.rs
|
|
@ -384,9 +384,11 @@ pub async fn backup_database(conn: &mut DbConn) -> Result<String, Error> { |
|
|
|
pub fn backup_sqlite_database(conn: &mut diesel::sqlite::SqliteConnection) -> Result<String, Error> { |
|
|
|
use diesel::RunQueryDsl; |
|
|
|
let db_url = CONFIG.database_url(); |
|
|
|
let db_path = std::path::Path::new(&db_url).parent().unwrap().to_string_lossy(); |
|
|
|
let file_date = chrono::Utc::now().format("%Y%m%d_%H%M%S").to_string(); |
|
|
|
let backup_file = format!("{db_path}/db_{file_date}.sqlite3"); |
|
|
|
let db_path = std::path::Path::new(&db_url).parent().unwrap(); |
|
|
|
let backup_file = db_path |
|
|
|
.join(format!("db_{}.sqlite3", chrono::Utc::now().format("%Y%m%d_%H%M%S"))) |
|
|
|
.to_string_lossy() |
|
|
|
.into_owned(); |
|
|
|
diesel::sql_query(format!("VACUUM INTO '{backup_file}'")).execute(conn)?; |
|
|
|
Ok(backup_file) |
|
|
|
} |
|
|
|
|
|
@ -604,7 +604,7 @@ async fn launch_rocket(pool: db::DbPool, extra_debug: bool) -> Result<(), Error> |
|
|
|
tokio::spawn(async move { |
|
|
|
let mut signal_user1 = tokio::signal::unix::signal(SignalKind::user_defined1()).unwrap(); |
|
|
|
loop { |
|
|
|
// If we need more singles to act upon, we might want to use select! here.
|
|
|
|
// If we need more signals to act upon, we might want to use select! here.
|
|
|
|
// With only one item to listen for this is enough.
|
|
|
|
let _ = signal_user1.recv().await; |
|
|
|
match backup_sqlite() { |
|
|
|